s[i] = (char) getchar();
时间: 2024-05-24 15:10:43 浏览: 51
用getchar函数输入一串字符,依次读入
This line of code reads a single character from the standard input and assigns it to the ith index of the character array s.
The function getchar() reads a single character from the standard input and returns its ASCII value as an integer. The (char) before the function call casts the integer value to a character before assigning it to the array.
This line of code is often used in a loop to read multiple characters from the input and store them in an array.
阅读全文