Code::Blocks - error: Stray ' 240'

Asked

Viewed 2,629 times

0

I am facing a simple problem, I believe. Saved my file in .cpp in Code::Blocks and then I try to compile it. However, when I compile, some errors appear (mingw compiler usage):

Erros aparentemente se referem à bibliteca <iostream>

Compiler Settings:

inserir a descrição da imagem aqui

Use Windows 8.1. Does anyone know how to solve? Simple code that shows errors:

#include <iostream>
using namespace std;
int main ()
{
 cout << "Hello World!"; return 0;
}
  • If you put your code maybe you can help. Only the error complicates. I have idea, but to answer I need to know what it is really about.

  • The code was added in the post.

  • No problems here: http://ideone.com/we0vY4 Did you write the file with some text encoding causing trouble?

  • Well, I don’t think so. I just programmed in C, so I don’t know how to set it up, see my compiler Settings in the post. I edited it with the image, if you can help me, I’m grateful.

2 answers

1

Typo error: has an invalid character somewhere in your source, probably an "á".

\240 = 128 + 32 = 160 (Alt+160 on Windows is "á")

  • The code was added in the post

1


Like mentioned by José, somewhere in your code there are unexpected characters, assuming you are using Unicode or ISO-8859-1, \240 can represent the character non-breaking space (blank space that does not allow line break).

This can happen when you copy the code from a website, perhaps because it contains non-readable characters that the compiler can’t understand (and you can’t see either), another cause may be the encoding you’re using, you can check in SettingsEditorOther SettingsEncoding.

Create a new project and try using the code below.

#include <iostream>

using namespace std;

int main() {
    cout << "Hello World!";
    return 0;
}
  • Yeah, you did. Thank you very much, I didn’t know that!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.