VS2013里面无法输出字符串,程序见内容

yshj1182831071 2015-04-15 01:17:02
/*talkkback.cpp -- 一个能为您提供一些信息的对话程序*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define DENSITY 62.4

int main(void)
{
float weight,volume;
int size,letters;
char name[40];
printf("Hi!What's your first name?\n");
scanf_s("%s",name);
printf("%s,what's your weight in pounds?\n",name);
scanf_s("%f",&weight);
size=sizeof name;
letters=strlen(name);
volume=weight/DENSITY;
printf("Well,%s,your volume is %2.2f cubic feet.\n",name,volume);
printf("Also,your first name has %d letters,\n",letters);
printf("and we have %d bytes to store it in.\n",size);

system("pause");

return 0;
}
程序如上所示,这一句printf("%s,what's your weight in pounds?\n",name);里面的name无法输出,并且第二个scanf_s也无法执行,编译器用的是VS2013,不知是什么原因,希望可以解答
...全文
337 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
苏叔叔 2015-04-15
  • 打赏
  • 举报
回复
跟着提示输入,没有问题,当然,字符串不要太长。
sprawling 2015-04-15
  • 打赏
  • 举报
回复
scanf_s("%s",name,20);
Aist-memory 2015-04-15
  • 打赏
  • 举报
回复
name里有东西吗? 读入可能有问题
Seagate_64 2015-04-15
  • 打赏
  • 举报
回复
1.程序编译完成后,进入dos目录执行程序就可以了 2.VS2013编辑器中显示信息使用TRACE函数

70,020

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧