程序如下:
#includevoid main()
{
int a,b;
long c;
unsigned long d;
unsigned int e;
char f;
float g;
scanf("%d,%d,%ld,%lu,%u,%c,%f",&a,&b,&c,&d,&e,&f,&g);
printf("int %d,%d,%d,%d,%d,%d,%d",a,b,c,d,e,f,g);
printf("unsigned int %u,%u,%u,%u,%u,%u,%u",a,b,c,d,e,f,g);
printf("long %ld,%ld,%ld,%ld,%ld,%ld,%ld",a,b,c,d,e,f,g);
printf("short %hd,%hd,%hd,%hd,%hd,%hd,%hd",a,b,c,d,e,f,g);
printf("signed char %c,%c,%c,%c,%c,%c,%c",a,b,c,d,e,f,g);
printf("float %f,%f,%f,%f,%f,%f,%f",a,b,c,d,e,f,g);
}
编译错误全部内容:
1>------ 已启动生成: 项目: 2-5 类型变换, 配置: Debug Win32 ------
1> 2-5 类型变换.cpp
1>c:\users\administrator\documents\visual studio 2012\projects\2-5 类型变换\2-5 类型变换\2-5 类型变换.cpp(10): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h(290) : 参见“scanf”的声明
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: 无法解析的外部符号 _WinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
1>C:\Users\Administrator\Documents\Visual Studio 2012\Projects\2-5 类型变换\Debug\2-5 类型变换.exe : fatal error LNK1120: 1 个无法解析的外部命令