I am trying to take text from a file and have it displayed using fprintf at line 46. When I run the below code nothing prints out. My text file has 4 lines with 5 different strings separated by whitespace.
Sorry I do have the fclose(fp) commented out in my work environment . I was not sure when I was going to close it so I commented it out.
I am trying to make it read out to the terminal. When I run the program I get nothing.
The file I am trying to open has text in it that I need to print to the terminal. I was going to print the first 50 chars to make sure that everything was working. I was thinking that fprintf was the function I needed to use without using c++ puts().
*print* is writing something you provide to something
%d denotes single integer
50 denotes number 50.
In no way this line can mean "read 50 character and output them to screen."
To output something from file you neet to read it first. Say by using fscanf() function:
1 2 3
char buffer [51] = { 0 };
fscanf(fp, "%50c", buffer); //Read 50 characters in buffer
printf("%s", buffer); //Print them to the screen