求vc6.0中使用scanf函数的例子,具体点的
4个回答
展开全部
的一般形式
scanf(格式控制,地址表列)
其中格式控制一定要是符合语法的。
可以修改:
#include<stdio.h>
void main()
{
int i;
printf("输入一个整数\n");
scanf("%d",&i);
printf("i=%d\n",i);
}
测试:
输入一个整数
236
i=236
Press any key to continue
最后建议lz先把书上的基本知识好好看看,要理解,然后再编编程序,在实践中检验自己的知识和编程能力,长期坚持的话,自己会提高很高的,要是有什么问题,以后我们可以交流一下!!!
scanf(格式控制,地址表列)
其中格式控制一定要是符合语法的。
可以修改:
#include<stdio.h>
void main()
{
int i;
printf("输入一个整数\n");
scanf("%d",&i);
printf("i=%d\n",i);
}
测试:
输入一个整数
236
i=236
Press any key to continue
最后建议lz先把书上的基本知识好好看看,要理解,然后再编编程序,在实践中检验自己的知识和编程能力,长期坚持的话,自己会提高很高的,要是有什么问题,以后我们可以交流一下!!!
立特为
2025-10-21 广告
LEADERWE立为包括立为设备有限公司和深圳市立特为智能有限公司,是一家专业提供电子、材料等领域分析及检测设备的综合服务供应商!LEADERWE 立为拥有一批有着丰富经验的销售人员以及专业的服务人员,不仅为您提供高端实用的设备,更能为您完...
点击进入详情页
本回答由立特为提供
展开全部
是输入函数的么,比如
#include <stdio.h>
void main( void )
{
int i;
scanf("%d",&i);
printf("%d",i);
}
这个就是输入一个数,在输出,最简单的了
#include <stdio.h>
void main( void )
{
int i;
scanf("%d",&i);
printf("%d",i);
}
这个就是输入一个数,在输出,最简单的了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以下载一下MSDN,里面的东西很好啊!以下内容摘自MSDN。
Example
/* SCANF.C: This program uses the scanf and wscanf functions
* to read formatted input.
*/
#include <stdio.h>
void main( void )
{
int i, result;
float fp;
char c, s[81];
wchar_t wc, ws[81];
printf( "\n\nEnter an int, a float, two chars and two strings\n");
result = scanf( "%d %f %c %C %s %S", &i, &fp, &c, &wc, s, ws );
printf( "\nThe number of fields input is %d\n", result );
printf( "The contents are: %d %f %c %C %s %S\n", i, fp, c, wc, s, ws);
wprintf( L"\n\nEnter an int, a float, two chars and two strings\n");
result = wscanf( L"%d %f %hc %lc %S %ls", &i, &fp, &c, &wc, s, ws );
wprintf( L"\nThe number of fields input is %d\n", result );
wprintf( L"The contents are: %d %f %C %c %hs %s\n", i, fp, c, wc, s, ws);
}
Example
/* SCANF.C: This program uses the scanf and wscanf functions
* to read formatted input.
*/
#include <stdio.h>
void main( void )
{
int i, result;
float fp;
char c, s[81];
wchar_t wc, ws[81];
printf( "\n\nEnter an int, a float, two chars and two strings\n");
result = scanf( "%d %f %c %C %s %S", &i, &fp, &c, &wc, s, ws );
printf( "\nThe number of fields input is %d\n", result );
printf( "The contents are: %d %f %c %C %s %S\n", i, fp, c, wc, s, ws);
wprintf( L"\n\nEnter an int, a float, two chars and two strings\n");
result = wscanf( L"%d %f %hc %lc %S %ls", &i, &fp, &c, &wc, s, ws );
wprintf( L"\nThe number of fields input is %d\n", result );
wprintf( L"The contents are: %d %f %C %c %hs %s\n", i, fp, c, wc, s, ws);
}
参考资料: MSDN
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdlib.h>
#include <stdio.h>
void main(
{
int a,b,c;
printf("please input a\n");
scanf("%d",&a);
printf("please input b\n");
scanf("%d",&b);
c = a + b;
printf("c is %d\n",c);
}
#include <stdio.h>
void main(
{
int a,b,c;
printf("please input a\n");
scanf("%d",&a);
printf("please input b\n");
scanf("%d",&b);
c = a + b;
printf("c is %d\n",c);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
更多回答(2)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询