简体   繁体   English

对于我的程序,我在程序中收到错误'stray'\\'160'

[英]I am getting the error 'stray '\160' in program ' for my program

I am getting the error 'stray '\\160' in program ' for my program. 对于我的程序,我在程序中收到错误'stray'\\'160'。

#include <stdio.h>

void main() {

    int x[500], n, my_numb, j, found;

    do {
        printf("Enter n < 10\n");
        scanf("%d",&n);
    } while ((n < 1) || (n > 10));
}

Unable to post entire program, but part of my program is as above. 无法发布整个程序,但我的程序的一部分如上所述。

Sounds like you found one of these . 听起来你找到了其中一个 It's a non-breaking space. 这是一个不间断的空间。 If you copied the code from a website, for instance, this would correspond to &nbsp;. 例如,如果您从网站复制代码,则这将对应于&nbsp;。 Unfortunately it's difficult to see it since it's a unicode whitespace. 不幸的是,很难看到它,因为它是一个unicode空白。 If you happen to be on a *nix system, try viewing the file with cat -vte . 如果您碰巧在* nix系统上,请尝试使用cat -vte查看该文件。

Is it possible you have a stray control code in your source file? 您的源文件中是否有可能存在杂散控制代码? Are you using an editor that shows unprintable characters, or Unicode embedded in the file? 您是否使用显示不可打印字符的编辑器或文件中嵌入的Unicode? I made a few changes to your program, and this compiles cleanly here. 我对你的程序做了一些修改,这里编译得很干净。 And runs without error. 并运行没有错误。 Also changed the logic in the while loop slightly so it matches what is being asked for. 还稍微更改了while循环中的逻辑,以便它与要求的内容相匹配。

#include <stdio.h>

int main(void)
{
   int x[500], n, my_numb, j, found;

   do {
      printf("Enter 0 < n < 10\n");
      scanf(" %d", &n);
   } while ((n < 1) || (n >= 10));
   return 0;
}

If you copy this into a new file on your own system, do you still see the error message? 如果将其复制到您自己系统上的新文件中,您是否仍会看到错误消息? I suspect you have corrupted it, or accidentally embedded a control sequence of some sort in your original program. 我怀疑你已经破坏了它,或者意外地在你的原始程序中嵌入了某种控制序列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM