+ 1

Is getchar() bad practice for C language?

I am learning from multiple sources and I came across getchar() and the gets() functions on here. The gets() function throws a red flag and I have read elsewhere that it is no longer a useable function in C. I am aware to use scanf() instead but I was wondering if that is also for the getchar() function? I don't want to get in to bad habits early on.

8th Jun 2020, 10:19 AM
Christina Hamblin
Christina Hamblin - avatar
6 Respostas
+ 1
Thanks Swim! Ur knowledge is much appreciated. Like I said before, I don't want to get into bad habits early on and I definitely don't want red flags all over my code.
8th Jun 2020, 12:59 PM
Christina Hamblin
Christina Hamblin - avatar
+ 1
Borland version uses getch(); and getche(); functions!!! _getch(); and _getche(); are operational(according to new standards of C/C++)... BTW, learn from a book implementing new standards!LOL
9th Jun 2020, 3:12 AM
DEATH128
DEATH128 - avatar
+ 1
C++17 is the latest ongoing Stable standard! 1. Professional C++ 4th edition by Marc Grégoire 2. The modern C++ challenge, packt publishing by Marius Bancila 3. C++17 in detail by Filipek 4. C++ primer series These are the best books with new content! But also expensive! Google them if you want them for free! 🤗
9th Jun 2020, 11:15 PM
DEATH128
DEATH128 - avatar
+ 1
Thanks! Much appreciated. I will check them out.
11th Jun 2020, 3:05 AM
Christina Hamblin
Christina Hamblin - avatar
0
DEATH128 I am definitely with u on this. I thought about it after I posted the question. Lol. Got to find something current to learn from! My main thing tho is that I want to learn good practices while im learning code. Everyone has an opinion about it and I find that most of the time u find the most efficient way of doing something by listening to others and putting it all together. Do you have any suggestions for fast, clean coding?
9th Jun 2020, 10:15 AM
Christina Hamblin
Christina Hamblin - avatar