I try read a story text file using c. the problem is i want one paragraf in one variabel. i am confuse how much i should alocate the buffer size?
#include <stdio.h>
int main() {
char buf[255]; <<HOW MUCH SHOULD WE ALOCATE TE BUFFER?
FILE* fp = fopen("somefile.txt","r");
if( fp == NULL) {
printf("Can't open the file\n");
return 1;
} // read each line of the file
while( fgets(buf,sizeof(buf),1,fp) != NULL) {
// count the lines or do other stuff here
}
// close the file fclose(fp); return 0; }
:cheesy:(sorry for my bad english, i hope u understand)