fp=fopen("%s\n", "w");
This will try to open a file for writing named "%s
" which I doubt will work.
Code:
FILE *fp;
fp=fopen("%s\n", "w");
printf("%s\n", &key);
char c;
while (c != NULL){
c = fgetc(fp);
printf("%s", &key);
}
And you're still doing this. I posted a more complete reply before you posted this code, so please stop using &key after you read it. It doesn't work for printf either.
Be aware that key will never change in that display loop. Based on what you've described, you could do it like this: edit tenchu's given example to fill up the array and then print the array whenever the array is full. Repeat this until the file is empty. Remember, you're working with strings!