To stop double printing of last time use this instead: #include int main() { FILE *file; char ch[40]; file = fopen("text.txt","r"); if(file==NULL) printf("File doesn't exist"); else { printf("File opened "); while(fgets(ch,100,file)) //syntax: fgets(variable name,size,filepointer); { printf("%s",ch); } fclose(file); } } New line at the end of the text file causes this issue. Because, enter/return is a character or string. This way while loop avoids that enter/return.
To stop double printing of last time use this instead:
#include
int main()
{
FILE *file;
char ch[40];
file = fopen("text.txt","r");
if(file==NULL)
printf("File doesn't exist");
else
{
printf("File opened
");
while(fgets(ch,100,file))
//syntax: fgets(variable name,size,filepointer);
{
printf("%s",ch);
}
fclose(file);
}
}
New line at the end of the text file causes this issue. Because, enter/return is a character or string. This way while loop avoids that enter/return.
Thank you ,,, Sir..
Sir Data structure :Link-List niye apnar kono video nai...please sir class gulo upload koren ❤️
nice
can't i use -----> fgets(ch, sizeof(ch), file); /*sizeof() fucntion*/
inside the while loop body
to solve the size declaring problem??
sir amar ekta problem hochche...build and run korar por o test file e kichu print hochchena
achha character data type kivabe integer value print korlo?
Same question
May be %s dewai hoieche.
But er ager video te %c die PC integer type data kemne read krche k jane?
e kane sir =25 2 bar print holo keno???
same qsn!
Same Question. My last line of the file also prints 2 times in the compiler.