LoneWolf
maybe?
Thanks, did you run the program, first of all why is it not terminating at first loop, dammit, is it the warning (which was at second loop) that I ignored?
LoneWolf
you don't provide us with enough context
Sorry, as I already mentioned, I will post the link soon, please bear with me, I'm only asking from that snippet.
LoneWolf
Wait, power is here.
LoneWolf
you don't provide us with enough context
Please, mention anything wrong that I'm doing instead of ignoring me.
BinaryByter
mainly because I dont know what to look for
BinaryByter
and I don'T ignore you
BinaryByter
I'm just waiting for you to send me enouhg context
LoneWolf
and I don'T ignore you
Its alright, I apologise for being a little impatient, I only get access to PC before 8pm.
LoneWolf
here the link
klimi
k ill grab it
LoneWolf
the code thats being discussed here is inside comments
klimi
hm
klimi
that too much work
LoneWolf
comments to the first(accepted answer).
klimi
im lazy
LoneWolf
wth ? removed the link, did anyone grab it ?
Aman
https://stackoverflow.com/questions/20970622/confused-about-getchar-and-scanf
LoneWolf
im lazy
C'mon, just ignore everything and go directly to the 9th comment by the guy named Salahuddin.
LoneWolf
LoneWolf
Meanwhile i will try to compile it again and paste the warning here, what else do you guys need any logs ?
klimi
use online compiler
LoneWolf
LoneWolf
check it out.
BinaryByter
you are waiting until the user enters the ASCII character 1
BinaryByter
Oh didn't know that
LoneWolf
LoneWolf
with warnings.
LoneWolf
Oh didn't know that
ofc, and then its supposed to terminate the first while loop, which it doesnt.
BinaryByter
you can't do what you do in line 12
LoneWolf
BinaryByter
what did i do wrong ?
the assignment operator doesnt return the assigned value
BinaryByter
atleast until you define it like that
LoneWolf
what EXACTLY do you want the program to do?
um, when i input a integer, its supposed to terminate.
BinaryByter
LoneWolf
When, i enter a character datatype, its supposed to run first loop, then enter second loop, run it until I input enter.
LoneWolf
i
LoneWolf
'm just trying to understand this code from stackexchange, by trying it myself. Is this bad practice ?
BinaryByter
Well the code is badly written
Dima
e.e
LoneWolf
Well the code is badly written
Maybe, but then I gave you the link, its not my code, I'm doing this to understand getchar() and scanf() better.
LoneWolf
where do you check for that?
I did, see second screenshot.
Aman
the character type's ASCII value is compared in comparison and ch is storing the ASCII value as it is of type int. So can we compare the integer and character types as in while we are comparing the value of getchar() stored in an int variable with '\n' ?
LoneWolf
shit, my screenshots are unreadable.
BinaryByter
now I know why I don't use C
LoneWolf
the character type's ASCII value is compared in comparison and ch is storing the ASCII value as it is of type int. So can we compare the integer and character types as in while we are comparing the value of getchar() stored in an int variable with '\n' ?
Thanks for reply, i actually wondered the same before power was gone, so, I tried to initialize ch with char type. The program gave wrong behaviour again. Wait, let me try it again.
LoneWolf
now I know why I don't use C
Sire, whats the matter ? I beg your pardon for any headache caused.
BinaryByter
I guess I got to resign on your question
LoneWolf
I guess I got to resign on your question
Dammit, this is embarrassing. I probably irked you by typing too much ?
LoneWolf
We have some progress here :
LoneWolf
LoneWolf
Hope, you guys can read the stuff from the screenshot provided, do tell me if you are facing problem.
LoneWolf
I'm supposed to read Head first C past the page number 50, and i wasted all my time trying to understand code snippets from stackexchange.
LoneWolf
Meh, i'm just too bad at C
Ohk, thanks for replies anyway.
Aman
Hope, you guys can read the stuff from the screenshot provided, do tell me if you are facing problem.
You have terminated the outer while loop after the condition only. So the second loop executes irrespective of the first loop
LoneWolf
You have terminated the outer while loop after the condition only. So the second loop executes irrespective of the first loop
Actually, I think its (outer while loop ) is supposed to terminate after I enter a integer, which will make scanf() return 1, and which will make while loop evaluate to false, which it doesn't.
LoneWolf
Dharmaraj
Ok so simple project but: 1. When I run the project it does create the text file in the location I wanted!! PROBLEM is : When I run the project again ... Then I edits the SAME FILE!!
Dharmaraj
Hence the previous data is gone
BinaryByter
thats normal
Dharmaraj
Any solutions? In easy way?
BinaryByter
Any solutions? In easy way?
change the file name everytime
BinaryByter
or use the std::append flag
LoneWolf
aarhhhh, a fucking misplaced semi colon
Dharmaraj
I am not familiar with std:: terms
Aman
aarhhhh, a fucking misplaced semi colon
https://hastebin.com/ihakotofiq.cpp. This is working
Dharmaraj
Please help me.. can anyone just get a sample code for it?
Dharmaraj
Just that function so that it creates new file ... Or edits the one but keeps existing data
Dima
read docs