#define password "abc\n"
My acquaintance with any language or coding is almost imaginary. This following code by an eminent personality used in his book, got on my meager imagination and made me feel again my inadequacies in this ground.
The level of my comprehensibility is ridiculed by these five characters “abc\n”.
Of course the code gives CORRECT response when the string “abc” is entered.
Could i get a little explanation on this (#define password “abc\n”) ?
\n is C language for carriage return/enter. If you read a book on C you will learn that very early, and you clearly need to read a book on C !
if you only want "abc" without enter (\n), you may use
fgets(&buff , Length ,stdin);
And be carefull when using gets().
If someone enters 500 characters, your program above, will -mostly- crash.
(gets() doesn't check buffer overflow. fgets() is safer).
Thank you …kodyazan
Yes...i will try to understand in depth what you have explained...
|All times are GMT -4. The time now is 05:08 PM.|
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.