Maybe my compiler sucks! because when I use every function in my whole code it doesn't work!
Maybe I'm the problem :lol:
anyway this function that I wrote solve my problem!
Maybe my compiler sucks! because when I use every function in my whole code it doesn't work!
Maybe I'm the problem :lol:
anyway this function that I wrote solve my problem!
It doesn't work only because you don't share your code.
You are a bad influence with your extremely unsafe, non-portable proprietary gets_v2 function.
Post your code already. Then maybe someone can help you do the right thing. Or you could stop doing C altogether. C is not a playground. I repeat: C is NOT a playground. It's an advanced language which sacrifices safety for speed.
Unless you KNOW what you're doing, you shouldn't be using C.
can you forget it!
I apologize to all for my bad words.
I didn't need help anymore about this issue
PLEASE FORGIVE ME
Well, your teacher is stupid (no offence to you).
There's no point, really. Anything you write will be unportable.if you're serious to help me help me to solve getstr() function that I wrote
Instead, just use fgets.
If you have this:
Then this translates into (using fgets):Code:char buf[50]; gets(buf);
Buffer is basically a storage area in memory where you can store stuff. The variable "buf" here is a buffer of 50 chars where you store the input from the user.Code:char buf[50]; fgets(buf, sizeof(buf), stdin);
But I do it before and it did'nt work
I don't remember what I've wrote, to post here
but in Turbo C (My Original code) when I trace it, fgets do nothing and next line execute!?
the same problem for gets. but when I use scanf it worked. but scanf wasn't what I need. so I wrote getstr.
Any way thank you very very much!
You're so kind!
I learned more about C
and forgive me for all bad thing I did
I also suggest you get rid of Turbo C. It's old, deprecated and not standard complaint.
You will find many other good IDEs here.
I suggest you upgrade.
As suggesting around post #2, you should not mix scanf with fgets (and equally gets - but you should not use gets at all). The reason you should not do that is that scanf() leaves first unused data in the input buffer. If you enter a number, that usually means a newline.Then fgets() will read data until the first newline - which is the first thing it finds in the input. So you don't get any data read in (other than the newline character itself).
You can work around this problem by adding a "getchar()" after the scanf() - but scanf is difficult to use anyways - try entereing "abc" when it expects a number, and I can almost certainly say that your program will loop "forever".
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.