主页
C 语言
C 用户输入
demo_user_input_c_multi
运行 ❯
×
更改方向
保存代码
更改主题
#include
int main() { // Create an int and a char variable int myNum; char myChar; // Ask the user to type a number AND a character printf("Type a number AND a character and press enter: \n"); // Get and save the number AND character the user types scanf("%d %c", &myNum, &myChar); // Print the number printf("Your number is: %d\n", myNum); // Print the character printf("Your character is: %c\n", myChar); return 0; }
Type a number AND a character and press enter: 5b
Your number is: 5
Your character is: b