1、用c语言编写一个程序使用type函数查看变量name、age、height三个变量存储的数据类型。条件:name=测试 age = 20 height = 175运行结果:class strclass intclass float
您可以使用以下代码来实现您的要求:
#include <stdio.h>
int main() {
char name[] = "测试";
int age = 20;
float height = 1.75;
printf("%s\n", typeof(name));
printf("%s\n", typeof(age));
printf("%s\n", typeof(height));
return 0;
}
请注意,C语言中没有内置的typeof函数来获取变量的类型。上述代码中使用了printf
函数来打印变量的类型。
原文地址: https://cveoy.top/t/topic/je8m 著作权归作者所有。请勿转载和采集!