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,

Recommended Answers

All 2 Replies

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.

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

Noobday

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.