Click to See Complete Forum and Search --> : test.cpp:15: error: stray ‘\160’ in program


joebar
August 30th, 2006, 11:21 PM
Hello,

when compiling sometimes I get the error above. I sense that it has to do with some character endcoding. It looks like it happens when I copy code I got via email into my source.

Any idea?

Cheers,
J.

laasunde
August 31st, 2006, 01:59 AM
How about showing us the code.

joebar
August 31st, 2006, 12:39 PM
It's the code someone else posted to a different question. I've copy and pasted it into an email, emailed that email to another computer and copy and pasted it back.




#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

char ChangeChar(char c)
{
if (c=='z' || c=='Z')
return c-=25;
else
return ++c;
}

int main()
{
string mystring("HelloZ");
cout << mystring << endl;
std::transform(mystring.begin(), mystring.end(),mystring.begin(),ChangeChar);
cout << mystring << endl;
return 0;
}

Krishnaa
August 31st, 2006, 12:52 PM
Try the code in attached file, I have copied it into ANSI format.

joebar
August 31st, 2006, 10:26 PM
No problem that one works fine.

I have copied the original code into an email on MS Outlook and copied the source from Linux kmail into kate to save the source file and compile it.

Your file I have donwloaded from linux directly.

Krishnaa
August 31st, 2006, 10:31 PM
No problem that one works fine.

I have copied the original code into an email on MS Outlook and copied the source from Linux kmail into kate to save the source file and compile it.

Your file I have donwloaded from linux directly.

Cool ! :wave:

joebar
September 1st, 2006, 12:31 AM
yes cool, but what does it mean?

harish_dixit1
September 1st, 2006, 01:08 AM
have a look on this
http://lists.samba.org/archive/distcc/2006q2/003396.html

joebar
September 1st, 2006, 12:22 PM
The link doesn't help me - sorry.

I acutally see the same source code in my text editor, what can I change in form of transmission to avoid that problem?

I have to do it via email I can't set up any network route or whatsoever.

Thanks.
J.

Krishnaa
September 1st, 2006, 12:45 PM
yes cool, but what does it mean?

I thought you said it works fine.

exterminator
September 1st, 2006, 01:50 PM
I have to do it via email I can't set up any network route or whatsoever.Who is your email provider? Contact them regarding the problem with proper steps to reproduce (STR).

Well, posting the STR here wouldn't harm either. I don't exactly understand your problem. Which email client are you using?

joebar
September 1st, 2006, 06:27 PM
Steps to reproduce:

1. Copy and Paste coding from codeguru.com into Outlook 2003 email on Win XP
2. Copy and Paste the coding received via email (kmail) into kate on Suse Linux 10.0.
3. Save kate file as any name
4. g++ -Wall file.cpp

Sorry don't get me wrong but, No way to contact my email provider, the text is there in my email. I can read the text so why would my email provider "waste" his time? Do you know any email provider who would spend time on this?

I only assume that it is due to character encoding, I can't think of anything else, but who knows.

What does stray \160 mean?

exterminator
September 2nd, 2006, 04:01 AM
Okay, attach the same file here that creates the problem.

I am not sure if I can help you (its hard to replicate the configuration that you have) but one issue that I can think of could be line-end issue. Whenever you move a file saved in windows to linux/unix - there is a well-known problem related to the line ends. A special Cntrl-M character appears in the file when opened on unix - you could view them using vim. Try using the dos2unix command for the file and try compiling.

I will look further if I can help you - but don't rely on that.. have workarounds (I think you already have that). Regards.

joebar
September 5th, 2006, 09:21 PM
File which gives this problem is attached. Any help is appreciated.

vi doesn't show any ^M, nor does a dos2unix command help.

J.