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");
                        }

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.