gpt4 book ai didi

c++ - Linux 和 C++ 编程错误 :\194 and error:\168

转载 作者:太空宇宙 更新时间:2023-11-04 09:02:02 24 4
gpt4 key购买 nike

在 linux(centos4.8 服务器版)上编写代码,尽管代码正确,但不断出错。下面显示的代码不是从任何地方复制和粘贴的,因为我正在输入它,因此没有机会输入垃圾字符。代码如下:-

#include <iostream>                               // L:1
using namespace std; // L:2

int main() // L:3
{
int i; // L:4
cout << "Enter the no: - "; // L:5
cin >> i; // L:6
cout << "The number entered is: - " << i; // L:7
return 0; // L:8
}

It gives me error as follows: -
line 5: error: stray '\194' in program
line 5: error: stray '\168' in program
line 5: error: `Enter' was not declared in this scope
line 5: error: expected `;' before "the"
line 5: error: stray '\' in program
line 5: error: stray '\194' in program
line 5: error: stray '\168' in program
line 7: error: `The' was not declared in this scope
line 7: error: expected `;' before "number"
line 7: error: stray '\194' in program
line 7: error: stray '\168' in program

请注意:- 我必须键入 "s(双引号)按钮两次才能将其打印出来每次在屏幕上同时包含字符串字符..我理解这个错误与解析错误计算有关,因此它给出了杂散的字符并以错误的标记结尾,所以我查看了同一源的 HEXCODE 格式在垃圾字符 C2(十六进制)上删除代码并删除相同的所有错误: -

error:  stray '\194' in program 

消失了,但其余的仍然存在。

我的 GCC 编译器版本是:

g++ -v(command)
... skipping the option details
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)

最佳答案

您的文件编码错误。

您很可能从网页上粘贴了“花哨的引号”(如 ʺ ˝ ˮ ˵ ˶ ̈ ̎ ̏)。

将其保存为 latin1 或 UTF-8,并确保您没有粘贴有趣的字符。

修复 namespace 中的拼写错误,您就可以开始了:

#include<iostream>
using namespace std;

int main()
{
int i;
cout << "Enter the no: - ";
cin >> i;
cout << "The number entered is: - " << i;

return 0;
}

关于c++ - Linux 和 C++ 编程错误 :\194 and error:\168,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19426026/

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