-
i have a question i want to find the size of the names i entered so i can loop that amount to process that amount for there ages
Code:
struct family { // family database
char name[BUFSIZ];
unsigned age;
} tree[BUFSIZ];
Code:
size = sizeof name
printf("there size = %d", size);
returns: 512
-
What were you expecting it to return? It returns the amount of memory taken up in memory by name. If you want to figure out how many indicies of name you've used, keep a separate counter.
-
-
Yes, use strlen(). sizeof() an array will return how much memory the array takes up. (To figure out how many elements are in the array, divide that number by the size of one element: sizeof(array)/sizeof(array[0]).) strlen() will return the length of the string stored in the array.
-
65 posts - is it done yet?
Ask another question in a new thread if you still have specific issues.