Can somebody tell me why this only reverses the last word in the data file, and not all the texti in the file?
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE *datain, *dataout;
char filenamein[15], filenameout[15], str[] = "";
printf("Enter input filename: ");
gets(filenamein);
printf("Enter output filename: ");
gets(filenameout);
datain = fopen(filenamein, "r");
dataout = fopen(filenameout, "w");
while (! feof(datain))
fscanf(datain, "%s", str);
fprintf(dataout,strrev(str));
return 0;
}