+ 1

I have a question about C language .Why didn't it end when I entered 0 .

https://code.sololearn.com/c5EU5Kw3VeDA/?ref=app

17th Nov 2020, 5:37 AM
[No Name]
[No Name] - avatar
15 Antworten
+ 4
tum kya karna chahte ho , aapka question not understand
17th Nov 2020, 10:45 AM
Ashutosh k.
Ashutosh k. - avatar
+ 3
are you telling about return 0
18th Nov 2020, 10:38 AM
Ashutosh k.
Ashutosh k. - avatar
+ 1
Why do you expect the program to end when you enter 0?
17th Nov 2020, 5:33 PM
Davide
Davide - avatar
+ 1
Because I think when I type 0, it can end up outputting the list.
18th Nov 2020, 5:20 AM
[No Name]
[No Name] - avatar
+ 1
Can you refer the piece of code that do that? The line that say that if the input is a zero tgen the program should print the list
18th Nov 2020, 10:29 AM
Davide
Davide - avatar
+ 1
return 0; it's not gonna do what you want 🤭🤗🤗 read this: https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c In main() you call creat() and then in the next line, print() So your program print the list right after creating it. I don't know exactly when the program strops to create the list. What's the utility of "n" in the while of creat()?
18th Nov 2020, 11:01 AM
Davide
Davide - avatar
+ 1
Anyway you just need to add a command to exit creat() when you scan a 0. Also you don't need to put "f" in the structure. And since your structure contain only a name, you could use a 2D array. But if you are exercising on data structures go on.
18th Nov 2020, 11:06 AM
Davide
Davide - avatar
+ 1
No, I mean when I use this program, I enter some data first, and then when I don't want to enter data, I enter 0, which ends the storage of data, but when I enter 0, the program does n' t end storage, so I want to know where I was wrong.
18th Nov 2020, 11:11 AM
[No Name]
[No Name] - avatar
+ 1
How can print a charater value in my program
18th Nov 2020, 2:50 PM
Chacha Joseph
Chacha Joseph - avatar
+ 1
You are welcome 🤗 As you can see the Q&A section has rules. If you want help with your program create a question posting your code and explaining your problem.
18th Nov 2020, 2:55 PM
Davide
Davide - avatar
0
You need to change the while condition to while( p1->f ) And when you read "f" you need to type 0 not "f". If you type a character, rather than a number, the scanf with %d fails
18th Nov 2020, 11:29 AM
Davide
Davide - avatar
0
Thank you for welcoming me
18th Nov 2020, 2:52 PM
Chacha Joseph
Chacha Joseph - avatar
0
Try return(1)
18th Nov 2020, 3:17 PM
Bilal Belli
Bilal Belli - avatar
0
Well, thank you very much. I know what I should do.
18th Nov 2020, 3:55 PM
[No Name]
[No Name] - avatar