write a C program to store the name of a student and then display the same
时间: 2024-02-21 10:57:12 浏览: 102
用C语言写的一个学生管理系统
Certainly! Here's an example program in C that prompts the user for their name, stores it in an array of characters, and then displays it back to them:
```
#include <stdio.h>
int main() {
// Declare an array to hold the name
char name[100];
// Prompt the user for their name
printf("Please enter your name: ");
scanf("%s", name);
// Display the name back to the user
printf("Your name is: %s\n", name);
return 0;
}
```
When you run this program, it will ask the user to enter their name. Once they do so and press Enter, the program will store the name in the `name` array and then print out a message that includes the name. Note that the `%s` format specifier is used to print out a string of characters (i.e., the name).
阅读全文