|
发表于 2021-11-18 22:28:01
|
显示全部楼层
不要用 _s 版本的函数
- #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 name?\n");
- //scanf_s("%s", &name);
- scanf("%s", name);
- printf("%s,What's your weight in pounds?\n", name);
- //scanf_s("%f", &weight);
- scanf("%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 letter,\n", letters);
- printf("and we have %d bytes to store it.\n", size);
- return 0;
- }
复制代码 |
|