#include <stdio.h>
int main() {
int num1;
printf(\nEnter a number: );
scanf(%d, &num1);
printf(\nYou entered %d\n , num1);
return 0;
}
局部范围变量与其原始函数相关联,可以在其他函数中重用变量名称。
#include <stdio.h>
int getSecondNumber(); //function prototype
int main()
{
int num1;
printf(\nEnter a number: );
scanf(%d, &num1);
printf(\nYou entered %d and %d\n , num1, getSecondNumber());
}
int getSecondNumber ()
{
int num1;
printf(\nEnter a second number: );
scanf(%d, &num1);
return num1;
}