Error while Serially Printing (Accept: */*)

HI,
I am trying to print Accept: / by this command Serial.print("Accept: /"); but while compiling IDE generates this error "Missing the /from the end of the / comment*/". So please can anyone tell me how can i send code to serial port.

Thank you

There is probably a neater way, but this should work:

Serial.print("Accept: */");
Serial.print("*");

A multi-line comment begins with /* and ends with */, so your original code is being interpreted as having a comment in it.

Thank you it works

Which version of the IDE are you using ?

Serial.print("Accept: */*");

works OK in release 1.5.6-r2

I am using release 1.0.6

If you ever get a combination of characters that's bothersome in a string, you can always close the string and immediately open another (by inserting a pair of inverted commas ""). When the compiler comes across such a pair of strings, it will simply concatenate them to be one string again.

So to get around your problem you could simply replace

Serial.print("Accept: */*");

With

Serial.print("Accept: */""*");

The same works when you need to put the hex character into a string, followed by a character that could otherwise be interpretted as hex. (for example to print degrees centigrade)

eg

lcd.print("Temp 35.7\xdf""C");

or escape the /

Serial.println("/");

robtillaart:
or escape the /

Serial.println("/");

Doesn't work.

Arduino: 1.0.6 (Windows XP), Board: "Arduino Mega 2560 or Mega ADK"
java.lang.RuntimeException: Missing the / from the end of a / comment */

Just to point out that this is an IDE bug. Comments should be ignored in quoted strings. After all, your output may be a computer program. (cf Yacc)

KeithRB:
Just to point out that this is an IDE bug. Comments should be ignored in quoted strings. After all, your output may be a computer program. (cf Yacc)

Totally agree.

I was just reassuring murtaza that he had done nothing wrong. 8^)

Thank you all for your help I really appreciate it.

IDE 1.5.8 compiles OK.