how can I get the size of this 'buffer':
FILE *filestream;
filestream = fopen("testFile.txt", "r+"};
char *buffer;
size_t count;
fseek(filestream, 0, SEEK-END);
count = ftell(filestream) + 1;
rewind(filestream);
buffer = (char*) malloc(count);
printf("buffer size: %d\n", sizeof buffer);
I keep getting 4, for the pointer. which actually makes sense .. I
think. So how can I find out the size of the 'buffer' that buffer
points to?
Also one more question.
size_t itemsize = sizeof(char);
size_t returnvalue;
returnvalue = fread(buffer,itemsize, count, filestream);
printf("fread returns: %d\n", returnvalue);
printf("fread read filestream into buffer, see: %s\n", buffer);
The final printf function won't work rigth, unless I add one more byte
to the buffer...i.e.
count = ftell(filestream) + 1;
as I did above. Why do I have to add 1 more byte?