I'm trying to extract string line by line from a file but its giving me no output.The file has some words in a token wise.Here is my code :
#include<stdio.h>
#include<string.h>
main(void)
{
FILE *open;
open = fopen("assembly.txt", "r");
FILE *write;
write = fopen("tokens.txt", "w");
FILE *a;
char ch;
char *str;
while ((ch = fgetc(open)) != EOF)
{
if (ch == 32 || ch == ',' || ch == '#')
fprintf(write, "\n");
else
fprintf(write, "%c", ch);
}
a = fopen("tokens.txt", "r");
while (!feof(a))
{
if (fgets(str, 126, a))
printf("%s", str);
}
}
I'm getting no output at all.The program executes successfully without any output!