Compiler error - Missing terminating ' character

Posted by Simmons on Thu 15 Jan 2004 05:10 PM — 5 posts, 18,075 views.

#0
Can anybody please help me solve this problem..

While compiling the code I get an error which reads "Missing terminating ' character".
The error line on the source code is like this

const char SEPARATOR = '^M'; // Control character (Return)

I tried changing '^M' with '\013' still it gives same the error message

My environment is as follows

Linux version 2.4.9-e.24smp
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-118.7.2)) #1 SMP Tue May 27 16:07:39 EDT 2003

thanks
Simmons
USA #1
The reason this is happening is that a character can only be of length one, and ^M is of length two.

What exactly is this a separator for? If you're replacing with \013, do you mean \n perhaps?
Australia Forum Administrator #2
I tried this:


int main (void)
  {
  const char SEPARATOR = '\013';
  return 0;
  }


That did not give an error, however octal 13 is not a normal 'return'. As Ksilyan says, you probably want \n for a newline or \r for a carriage return.

In fact \013 is a vertical tab character, which you could represent as \v.

I would be cautious that the ^M you are showing is actually a carriage-return introduced when you copied a file from Windows to Linux. You may need to run it through some sort of return-stripper. One approach would be to use your text editor to remove all of them. There is also a dos2unix program available for download from this site. Alternatively, use "text" (ascii) mode when you ftp the file from Windows to Linux.
#3
Thanks for the responses......

But I'm still not able to do away with the error message (even with trying with \n or \r). My program requires to parse a message which has got these characters(^M, is a literal control character, like you would get in emacs by
typing C-qC-M ) in it. (The message generation is not in our control).

Is it has got something to do with the environment (I mean the gcc)
Linux version 2.4.9-e.24smp
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-118.7.2)) #1 SMP
Amended on Thu 15 Jan 2004 11:49 PM by Simmons
USA #4
\n or \r are also "literal control characters" in this case. It seems that in this case you may want to be using \r, not \n.

I tried out what Nick did as well and got no trouble. The line:
const char separator = '\n';
gives me no trouble at all.

Maybe you can just do:
#define SEPARATOR '\n'
or
#define SEPARATOR "\n"


which may work, depending on what you're trying to do exactly.

By the way, this isn't SMAUG, right?