Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ Compiling the server
➜ Compiler error - Missing terminating ' character
|
Compiler error - Missing terminating ' character
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Simmons
(2 posts) Bio
|
| Date
| Thu 15 Jan 2004 05:10 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Thu 15 Jan 2004 07:48 PM (UTC) |
| Message
| 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? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Thu 15 Jan 2004 08:16 PM (UTC) |
| Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Simmons
(2 posts) Bio
|
| Date
| Reply #3 on Thu 15 Jan 2004 11:46 PM (UTC) Amended on Thu 15 Jan 2004 11:49 PM (UTC) by Simmons
|
| Message
| 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
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #4 on Thu 15 Jan 2004 11:56 PM (UTC) |
| Message
| \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:
or
which may work, depending on what you're trying to do exactly.
By the way, this isn't SMAUG, right? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,219 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top