c语言输入姓名输出姓和名
Input means to provide the program with some data to be used in the program and Output means to display data on screen or write the data to a printer or a file.
输入装置为程序提供一些要在程序中使用的数据, 输出装置为在屏幕上显示数据或将数据写入打印机或文件。
C programming language provides many built-in functions to read any given input and to display data on screen when there is a need to output the result.
C编程语言提供了许多内置函数,可以读取任何给定的输入并在需要输出结果时在屏幕上显示数据。
In this tutorial, we will learn about such functions, which can be used in our program to take input from user and to output the result on screen.
在本教程中,我们将学习这些功能,这些功能可在我们的程序中用于从用户那里获取输入并在屏幕上输出结果。
All these built-in functions are present in C header files, we will also specify the name of header files in which a particular function is defined while discussing about it.
所有这些内置函数都存在于C头文件中,我们还将在讨论该文件时指定在其中定义了特定功能的头文件的名称。
scanf()
和printf()
函数 (scanf()
and printf()
functions)
The standard input-output header file, named stdio.h
contains the definition of the functions printf()
and scanf()
, which are used to display output on screen and to take input from user respectively.
标准输入输出头文件stdio.h
包含函数printf()
和scanf()
的定义,这些函数用于在屏幕上显示输出并分别从用户处获取输入。
#include<stdio.h>
void main()
{
// defining a variable
int i;
/*
displaying message on the screen
asking the user to input a value
*/
printf("Please enter a value...");
/*
reading the value entered by the user
*/
scanf("%d", &i);
/*
displa