c语言程序运行错误?
#include<stdio.h>#include<string.h>#defineDENSITY62.4;intmain(){floatweight,volume;in...
#include<stdio.h>
#include<string.h>
#define DENSITY 62.4;
int main()
{
float weight, volume;
int size, letters;
char name[40];
printf("hi!what's your first nane?\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 ie.\n", size);
return 0;
}在vs2017运行这个程序以后,输入name以后程序就终止了。请问哪里有错呢? 展开
#include<string.h>
#define DENSITY 62.4;
int main()
{
float weight, volume;
int size, letters;
char name[40];
printf("hi!what's your first nane?\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 ie.\n", size);
return 0;
}在vs2017运行这个程序以后,输入name以后程序就终止了。请问哪里有错呢? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询