0

我正在尝试在 24 小时内从 Sam's Learn C 编译一个示例。

当我尝试编译以下代码时出现错误:

/* 03L02.c: Calculate an addition and print out the result */
#include <stdio.h>
/* This function adds two integers and returns the result */
int integer_add( int x, int y )
{
    int result;
    result = x + y;
    return result;
}
int main()
{
    int sum;
    sum = integer_add(5, 12);
    printf(“The addition of 5 and 12 is %d.\n”, sum);
    return 0;
}

这是我的编译器给出的错误:

In function main
stray "\147\' in program
The undeclared identifier is declared only once
for each function it appears in
syntax error before addition
stray "\' in program
stray "\148' in program

提前致谢。

4

5 回答 5

3
于 2012-12-03T11:44:12.073 回答
1

您只是弄错了引号字符,将其更改为:

printf("The addition of 5 and 12 is %d.\n", sum);

我不知道您使用的是什么键盘,但通常 " 字符位于 '2' 字符上方(我使用的是意大利键盘,所以您所在国家/地区的键盘可能有所不同)。
您肯定会在某个地方找到该字符。
如果我m 没记错它在 ASCII 表中是 34,所以在 windows 上你可以通过按 alt+34 来获取它。

于 2012-12-03T11:46:51.200 回答
0

because of wrong double qoute

printf(“The addition of 5 and 12 is %d.\n”, sum);

to

printf("The addition of 5 and 12 is %d.\n”, sum);
于 2012-12-03T11:45:06.457 回答
0

Don't use "smart quotes" in code!!!!! For string delimiters use plain old quotes. Here ("""""""""""""") are a few (here single quotes: '''''''''''''') you can probably copy/paste :)

于 2012-12-03T11:45:50.173 回答
0

我看到你的错误是因为相同的字符。查看您的代码

printf(“The addition of 5 and 12 is %d.\n”, sum);

尝试更改为:

printf("The addition of 5 and 12 is %d.\n", sum);

你能看出区别吗?Qoute“它必须是”

于 2017-02-21T13:54:04.340 回答