[SOLVED] Confusion in C scanf() | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

[SOLVED] Confusion in C scanf()

What does %10 mean here; char str[11]; scanf("%10[0-9a-zA-Z ]", str); Source: https://stackoverflow.com/a/1247993

5th Oct 2020, 10:54 AM
Bibek Oli
Bibek Oli - avatar
3 Respostas
+ 3
The number means the maximum characters to be stored into str. Extra characters will be stored into buffer. Check the comments under the answer in the original post. They also mentioned that. https://www.sololearn.com/learn/C/2914/
5th Oct 2020, 10:59 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 1
CarrieForle seen but, still confused... I knew we can do that for limit the input length. But no format specifier like s, c , d, etc. used there. I don't find comment relating to this?
5th Oct 2020, 11:13 AM
Bibek Oli
Bibek Oli - avatar
+ 1
Bibek Oli AProgrammer and paxdiablo has discussed the s under the answer.
5th Oct 2020, 11:27 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar