Is there a good Valgrind substitute for Windows?
Some more good commercial tools: Purify Insure++
Some more good commercial tools: Purify Insure++
A char in C is already a number (the character’s ASCII code), no conversion required. If you want to convert a digit to the corresponding character, you can simply add ‘0’: The ‘0’ is a character in the ASCll table.
What does it mean? “error: too few arguments to function ‘printDay’” means you’re passing the wrong number of argument to printDay when you call it here: You’re passing one argument but your declaration of printDay shows that it takes 3 arguments: How do I fix this? You can fix it by passing the correct number of arguments, e.g:
I’ll explain the first error to you. At line 331, you’re probably reading an (unsigned) int, in a part of the memory you haven’t allocated for your own program. This part gives more information about the part of memory you tried to read. It says you’ve already used the memory, but reallox freed it. That … Read more
If you’re on Sierra , that’s expected. GDB isn’t compatible with macOS Sierra , even the last release (7.12). We should maybe wait for another release of GDB , or for another update for macOS in order to get the bug fixed.
It also happens if you’re trying to access an instance when you have a pointer, and vice versa: As pointed out in a comment, this can be made excruciating if someone goes and typedefs a pointer, i.e. includes the * in a typedef, like so: Because then you get code that looks like it’s dealing with instances, when in fact … Read more
C lets you use the subscript operator [] on arrays and on pointers. When you use this operator on a pointer, the resultant type is the type to which the pointer points to. For example, if you apply [] to int*, the result would be an int. That is precisely what’s going on: you are passing int*, which corresponds to a vector … Read more
The reason for the warning is that the compiler suspects you might be trying to round-trip a pointer through int and back. This was common practice before the advent of 64-bit machines and it is not safe or reasonable. Of course here the compiler can clearly see that you’re not doing this, and it would be nice … Read more
While you can use malloc() here, it is not really necessary. You can #define a reasonable maximum line length, and declare a character array to hold the input. If you do this, you can remove the frees from your code. You also have an issue with the way that you are using fgets(). The trailing \n is kept by fgets(), but your comparisons are … Read more
You forgot to make p and q int pointers. Also, you forgot to use the format specifier in the printf statements. Try the following: