Reading a string from a file - C

electroRF

Member
Hi,
Could you tell me please why this code only prints the first word of the file?

char str[50];
FILE* pFile;

pFile = fopen("myFile.txt", "r");

if (NULL != pFile)
{

fgets(pFile, str);

printf("The first word in the file is %s\n", str);

fclose(pFile);
}



---
I got additional question please.

is it possible to move files from one directory to another with C?
 
Last edited:
Last edited:
Thanks guys!

@misterT
you're right, it works well now.

@Ian
I'm working with windows.
Is C# needed for copying files from one folder to another?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…