Hi, this is a simple task but i've been breaking my head over it for a day and can't figure out what the problem is. Any help would be good.
Code:
#include <stdlib.h>
# include <string.h>
#include <stdio.h>
#include <stdint.h>
int main(){
char key[10];
strcpy(key, " ");
FILE *pFile = fopen("testing", "a");
fprintf(pFile, "HELLO WORLD");
rewind(pFile);
int i = fscanf(pFile,key);
if (i=EOF){
printf("EOOOOOOOOF\n");
}
printf("%s\n", key);
fclose(pFile);
return 0;
}
Why is this printing EOOOOF then blank? I just want a simple program that reads from a file and stores a string without white spaces into a string. This is a simple task but for some reason it's always scanning from the end of the file therefore returning blank spaces into the string. Thank You for any help.