gpt4 book ai didi

c - 程序中的杂散字符 ("error: stray ’\223’")

转载 作者:行者123 更新时间:2023-11-30 18:20:45 24 4
gpt4 key购买 nike

我的教授在 Microsoft Word 中给了我们一些代码文档并说它应该能够编译,但我遇到了各种各样的错误,而且我不知道出了什么问题,因为我没有任何使用 C 的经验。

它是一个汇编语言类,我们应该编写汇编代码来匹配 C 代码正在执行的操作。他告诉我们用 C 语言运行该程序来感受一下。

#include <stdio.h>
#define SIZE 40

main()
{
int v[SIZE];
register int gap, i, j, temp;

/* Initialize array to random positive integers mod 256 */
for (i = 0; i < SIZE; i++)
v[i] = rand() & 0xFF;

/* Display the unsorted array */
for (i = 0; i < SIZE; i++)
printf(“v[%-d] = %-d\n”, i, v[i]);

/* Sort the array using a shell sort */
for (gap = SIZE / 2; gap > 0; gap /= 2) {
for (i = gap; i < SIZE; i++) {
for (j = i - gap; j >= 0 && v[j] > v[j + gap]; j -= gap) {
/* Exchange out of order items */
temp = v[j];
v[j] = v[j + gap];
v[j + gap] = temp;
}
}
}

/* Display the sorted array */
for (i = 0; i < SIZE; i++)
printf(“v[%-d] = %-d\n”, i, v[i]);
}

我得到的错误是在第 15 行和第 31 行中出现的错误,因此每一行都有一个 printf 。

As3.c: In function ’main’:
As3.c:15: error: stray ’\223’ in program
As3.c:15: error: expected expression before ’%’ token
As3.c:15: error: expected expression before ’%’ token
As3.c:15: error: stray ’\’ in program
As3.c:15: error: stray ’\224’ in program
As3.c:31:error: stray ’\223’ in program
As3.c:31:error: expected expression before ’%’ token
As3.c:31:error: expected expression before ’%’ token
As3.c:31:error: stray ’\’ in program
As3.c:31:error: stray ’\224’ in program

如何解决这个问题?

最佳答案

看起来有些角色变得“聪明”了,可能是通过 Microsoft Word 或类似的程序实现的。您需要执行查找和替换操作,将 更改为 " (对于其他字符可能也是如此,尽管 是您发布的特定编译错误中唯一提示的字符)。

关于c - 程序中的杂散字符 ("error: stray ’\223’"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13061457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com