Some easily overlooked knowledge in C language 2

1. The difference between gets and scanf

1. **gets can receive spaces; scanf will consider the input to end when it encounters spaces, carriage returns and Tab keys, so it cannot receive spaces. **For example: if the input is "hello world", the result of the above program is "hello world". And if you use scanf, you can only output hello.
2. Scanf 's processing of the end carriage return: keep the carriage return in the cache. Gets processing of the end carriage return: accept carriage return, but replace carriage return with \0.

二.a<b? a:b

It means that if a<b is true, return the value of a, otherwise return the value
of b. Example:
m=a<b?a:b
If a=1, b=2, then m=1;
if a=2, b= 1, then m=1; of
course a and b can also be expressions

Guess you like

Origin blog.csdn.net/weixin_50998641/article/details/110881607