0

I've been trying to compile a very simple c++ code ; when trying to compile on codeblocks it says : error - stray '\312' in program

#include <string>
#include <iostream>

using namespace std;

int main()
{
    char letter1, letter2;
    string lastName;
    cout << "Enter your two initials and last name ";
    cin >> letter1 >> letter2 >> lastName;
    cout << "Hello" << letter1 << "." << letter2 << "." << lastName << "!";
    cout << "Hope you enjoy C ++ " << endl;
    return 0;
}

I'm on mac however so that migth explain the problem,

Edited by Nick Evan: Fixed closing tag

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by noobday
1

Try deleting all the whitespace around that line. This character isn't visible, but might still be there.
>>I'm on mac however so that migth explain the problem
True. '\312' is hex 0xCA -- the "non-breaking space" in MacRoman encoding. So try removing whitespaces and re-add them. Maybe mac has somesort of setting for this, but I'm not a mac-user so I can't tell you for sure.

Edited by Nick Evan: n/a

0

thanks a million, the free invisible space was exactly the problem!

Noobday

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.