[英]C Program behaves differently if compiled using CLion rather than using gcc directly. Why?
I'm writing a program to play 4 in a row using C90.我正在编写一个使用 C90 连续播放 4 的程序。
I made a UI for the Console using ASCII characters.我使用 ASCII 字符为控制台制作了一个 UI。
If I compile the program using C Lion I get the following output:如果我使用 C Lion 编译程序,我会得到以下输出:
If I compile it using gcc main.c and then run./a.out I get the following result:如果我使用 gcc main.c 编译它然后运行 ./a.out 我会得到以下结果:
So obviously this dot character is sized differently if I compile it using gcc directly.所以很明显,如果我直接使用 gcc 编译它,这个点字符的大小会有所不同。
Has anyone any idea how this could possibly happen?有谁知道这怎么可能发生?
The code that is responsible for printing the game lines looks like this:负责打印游戏台词的代码如下所示:
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");
}
The code responsible for the colors looks like this: (If this makes any difference)负责颜色的代码如下所示:(如果这有什么不同的话)
/**
* 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;
}
}
The issue is the font choice for the CLion Console.问题是 CLion 控制台的字体选择。
After that ensure to use same-length strings for both the empty and the "ball'd" positions.之后确保对空位置和“球”位置使用相同长度的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.