Hi, I posted a very similar program to this one recently, but i'm still having trouble getting it to work. What i want to do is simply take text from a .txt file and have its contents copied to the console window. Now what's really baffling me is when I run this program in the debugger(MSVC++ 6.0), it tells me fscanf, and printf return a 1, and my if statement says if the function doesn't return a -1 to go ahead and process the next statement. Yet for some reason it skips the statements and only goes through the functions once. This is such a simple program and i'm still baffled. Well here's the code, if anyone knows what the problem is i'd greatly appreciate some help.
Code:
#include <stdio.h>
FILE *stream;
int main()
{
char txtstring[1000];
int cntr = 0;
stream = fopen("teachers.txt","r");
if( fscanf(stream,"%c",&txtstring[cntr]) != -1)
cntr++;
cntr = 0;
if( printf("%c",txtstring[cntr]) != -1)
cntr++;
return 0;
}