字符,字符串需要在scanf_s的第三项的输入能输入的最大字符数
#include<stdio.h>
#include<string.h>
#define DENSITY 62.4 //人体密度
int main()
{
float weight;
double volume;
int size;
unsigned long long int length;
char name[10];
name[9] = 0;
printf("what's your first name?\n");
scanf_s("%s", name,10);
printf("%s ,what's your weight in pounds?\n", name);
scanf_s("%f", &weight);
size = sizeof(name);
volume = weight/DENSITY ;
length = strlen(name);
printf("well,%s,your volume is %2.2f cubic feet.\n", name, volume);
printf("Your first name has %llu letters.\n",length);
printf("and we have %d bytes to store it .\n", size);
return 0;
}
其中strlen的返回值是size_t类型,无符号数的整数型