0

I have write a code to read data from a file and i try to put it in a queue but i don not know who to put in th queuue.IS anybody who can give an example???
my code is bellow:

if((fp=fopen("read.txt","r"))==NULL){
printf("\nERROR OPENNING THE FILE");
exit(1);
}
while(fgets(line,100,fp))
{
if (readline[0] == '0') {
		if (strcmp(s,"input") == 0) {
	           printf("type_0");
                        }
3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by jonnelgrande
0

well... the first 5 lines are okay...

on line 5 you fget the first line of the file and put it into the string "line"... that's fine too

but then on line 7, you start checking the string "readline" where does this come from? you should be checking the string "line", i think...

so you want to check if the first character of the line is the character "0", is that right? then change "readline" on line 7 to "line"

then on line 8 you are checking the string "s" to see if it contains exactly the string "input"... is that right? where did "s" come from? i have to assume that you must have filled it with its value previously.

0

Last day, we tried a code to read data from a file and print it(display)...

and it works...


we also used fopen in a different way

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.