首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

运行时,无输出结果是何原因?解决办法

2013-09-06 
运行时,无输出结果是何原因?#include stdio.h#include string.hint main (void){char s1[80],s2[80]u

运行时,无输出结果是何原因?

#include <stdio.h>
#include <string.h>
int main (void)
{
char s1[80],s2[80];
unsigned int i;
printf_s ("Input s2:");
scanf_s ("%s",s2);
for (i = 0; i <= strlen(s2); i++)
{
s1[i] = s2[i];
}
printf_s ("s1:%s\n",s1);
}

程序运行时,无输出结果是何原因?
[解决办法]
你的scanf_s用错了,改成:

scanf_s ("%s",s2,_countof(s2));

[解决办法]
引用:
Quote: 引用:

你的scanf_s用错了,改成:

scanf_s ("%s",s2,_countof(s2));

Error:未定义标识符countof


添加 #include <stdlib.h>

热点排行