Fatal error: ‘stdafx.h’ file not found

stdafx.h is the precompiled header used by Visual Studio, you do not need this. You seem to have missed out the int main() function It is std::endl not std::end1 So something like this:

Quick Way to Implement Dictionary in C

Section 6.6 of The C Programming Language presents a simple dictionary (hashtable) data structure. I don’t think a useful dictionary implementation could get any simpler than this. For your convenience, I reproduce the code here. Note that if the hashes of two strings collide, it may lead to an O(n) lookup time. You can reduce the likelihood of collisions … Read more

C free(): invalid pointer

You’re attempting to free something that isn’t a pointer to a “freeable” memory address. Just because something is an address doesn’t mean that you need to or should free it. There are two main types of memory you seem to be confusing – stack memory and heap memory. Stack memory lives in the live span of the function. … Read more

error: indirection requires pointer operand (‘int’ invalid)

The purpose of this code is to pass a virtual address in decimal and output the page number and offset. After I compile my code using the gcc compiler on Linux I get this error: indirection requires pointer operand (‘int’ invalid) virtualAddress = *atoi(argv[1]);

Categories C Tags

How do you pass a function as a parameter in C?

Declaration A prototype for a function which takes a function parameter looks like the following: This states that the parameter f will be a pointer to a function which has a void return type and which takes a single int parameter. The following function (print) is an example of a function which could be passed to func as a parameter because it is … Read more

expression must have integral type

I get that compilation error because of this line which intended to increase the pointer by 0x200 (to point to the next segment) I’v seen this but I didn’t use any illegal symbol! P.S. The initialization of the pointer:

malloc for struct and pointer in C

No, you’re not allocating memory for y->x twice. Instead, you’re allocating memory for the structure (which includes a pointer) plus something for that pointer to point to. Think of it this way: So you actually need the two allocations (1 and 2) to store everything. Additionally, your type should be struct Vector *y since it’s a pointer, and you should never cast the return value … Read more

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

Check the return value of strtok. In your code here strtok is returning a NULL pointer and according to documentation, A null pointer is returned if there are no tokens left to retrieve. which matches my original guess that because the address code is 0x0 there’s a NULL pointer deference somewhere. Obviously, the following call to atoi is expecting a non-NULL pointer … Read more