#include "stdio.h"
int main(void)
{
printf("\n========== PC 上表示範圍 ===========\n\n");
printf(" short:(%d)\n", sizeof(short));
printf(" int:(%d)\n", sizeof(int));
printf(" long:(%d)\n", sizeof(long));
printf(" float:(%d)\n", sizeof(float));
printf(" double:(%d)\n", sizeof(double));
printf(" char:(%d)\n", sizeof(char));
printf("\n========== 型態格式 ===========\n\n");
int int_type = 10;
double double_type = 3.14159;
char ch1 = 'A';
char ch2[4] = "NTU"; //宣告buffer的長度至少要字串+1, 避免字串儲存錯誤
printf(" int(Dec):(%d)\n", int_type);
printf(" int(Dec):(%i)\n", int_type);
printf(" int(Hex):(0x%x)\n", int_type);
printf(" int(Oct):(0x%o)\n\n", int_type);
printf(" double:(%f)\n", double_type);
printf(" double:(%e)\n", double_type);
printf(" double:(%E)\n", double_type);
printf(" double:(%g)\n", double_type);
printf(" double:(%G)\n\n", double_type);
printf(" char:(%c)\n", ch1);
//printf(" char:(%s)\n", ch1); //無法使用
//printf(" string:(%c)\n", ch2); //造成亂碼
printf(" string:(%s)\n", ch2);
printf("\n========== End ===========\n\n");
return 0;
}
沒有留言:
張貼留言