Saturday, May 22, 2010

In C, what is the difference between * and **.?

Like a FILE * and a FILE **. I used to think it was a typo when the was two asterisks, but now I have realized thta it actually is something different. What is it? It seems hard to imagine it being a pointer to a pointer lol

In C, what is the difference between * and **.?
FILE * is a pointer to a certain memory address which contains a FILE object. This can simply point to another FILE, or it can be used to point to a space in memory that has been allocated with malloc to hold an array of FILE's. If this is the case, you can access it like an array, like file[2], for example.





FILE ** is a pointer to a pointer, and it operates much like a FILE *, but if it is allocated correctly, could be an array of arrays, accessed like file[3][2];





I recommend you read up on memory address/allocation, pointers, and arrays. http://cprogramming.com is a good place to start.
Reply:FILE * is a pointer to a FILE type, it is a pointer to to the address in memory.





FILE ** is a pointer to a pointer to a FILE type, so it is a pointer to the address value.





FILE * can also be thought of as an array of FILEs





FILE** is an 2D array of FILEs,








Hope this helps


No comments:

Post a Comment