[英]C Program behaves differently if compiled using CLion rather than using gcc directly. Why?
我正在编写一个使用 C90 连续播放 4 的程序。
我使用 ASCII 字符为控制台制作了一个 UI。
如果我使用 C Lion 编译程序,我会得到以下输出:
如果我使用 gcc main.c 编译它然后运行 ./a.out 我会得到以下结果:
所以很明显,如果我直接使用 gcc 编译它,这个点字符的大小会有所不同。
有谁知道这怎么可能发生?
负责打印游戏台词的代码如下所示:
void printGameLine(int line[7]) {
int i;
printf("┃");
for (i = 0; i < 7; ++i) {
printColor(line[i]);
line[i] == 0 ? printf(" ") : printf(" ⬤ ");
printColor(0);
printf("┃");
}
printf("\n");
}
负责颜色的代码如下所示:(如果这有什么不同的话)
/**
* prints the color
* @param player -1 First player, 0 neutral, 1 Second Player
*/
void printColor(int player) {
switch (player) {
case 1:
printf("\033[0;31m"); /*red*/
break;
case -1:
printf("\033[0;33m");/*yellow*/
break;
default:
printf("\033[0m");/*neutral*/
break;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.