I have below program,
void Print()
{
printf("\nCall from Print\n");
}
int main()
{
FILE * pFile;
char mystring [100];
pFile = freopen ("myfile.txt" , "r", stdin);
if (pFile == NULL)
{
perror ("Error opening file");
}
else
{
if ( fgets (mystring , 100 , pFile) != NULL )
{
freopen("myfile.txt" , "a", stdout);
Print();
printf("Here it is\n");
//puts (mystring);
}
fclose(stdout);
fclose (pFile);
}
printf("Hello World\n");
return 0;
}
Now when I am execting the program I can not see the output in console window. All the outputs are redirected into myfile.txt
file. I want the output should come in both console
and myfile.txt
too.
After all that why printf("Hello World\n")
is not getting printed in console.
How to make it printed in console also?
My am working in windows-7, visual studio-2010