I am trying read a text from file in C but I am getting nothing in command prompt.Here my code is,please help me ...
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *file=NULL;
file = fopen("C:\\Users\\ylmzt_000\\Desktop\\Yeni klasör\\deneme.txt", "r");
if(file != NULL)
{
printf("----------------\n");
printf("content\n");
printf("-----------------\n");
int ch;
while((ch=fgetc(file)) != EOF)
{
putchar(ch);
}
printf("\n");
fclose(file);
}
return 0;
}
If fopen()
returns NULL, an error occured. Construct an else
part which may contain
fprintf(stderr, "cannot open '%s' (%s)\\n", fn, strerror(errno));
where fn
contains your filename.
Also see http://linux.die.net/man/3/fopen for further hints.
There is no obvious problem in your code. The problem may be related to the fact that the filename contains non-ASCII characters:
C:\\Users\\ylmzt_000\\Desktop\\Yeni klasör\\deneme.txt
Try renaming the directory with only ASCII characters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.