Solved

Escape character in c program (linux op)

Posted on 2003-11-21
5
1,228 Views
Last Modified: 2010-04-15
I am trying to compile a c program in linux using cc -o

it is coming up with bad escape character on multiple line

here in one example of code

sprintf(chkval -> shpdate, "%02d\/%02d\/%04d", MM,DD,YY);

it doesn't like %02d\/%02d\/%04d

Another example

char *Imrgn="\33\46\141\64\114";

it does like what's it between the quotes



does anyone know if it is a bad ecape character?
0
Comment
Question by:jmsloan
5 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9798850
Why do you escape the slashes ? Just

sprintf(chkval -> shpdate, "%02d/%02d/%04d", MM,DD,YY);
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9798877
That doesn't work either.  When I take out the % then it works, but I still have an issues with

char *Imrgn="\33\46\141\64\114";

not working.
0
 
LVL 16

Accepted Solution

by:
_nn_ earned 50 total points
ID: 9798913
>> That doesn't work either.  

Please be *specific*. What doesn't work ? What are the error messages ? Possibly the wrong syntax is a couple lines before that one. The syntax I provided is definitely correct.

>> I still have an issues with
>>
>> char *Imrgn="\33\46\141\64\114";

What is this supposed to be in the first place ? Please try :

char *Imrgn="\x21\x2E\x8D\x40\x72";
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9801594
char *Imrgn="\33\46\141\64\114";

I imagine you actually want the string

\33\46\141\64\114

in that case, use

char *Imrgn="\\33\\46\\141\\64\\114";

\ is used as beginning of an escape sequence ... its is a special char ... if you wish to use it literally (as a back slash) then you need to escape it with another \

0
 
LVL 1

Expert Comment

by:imstaff
ID: 9922284
char *Imrgn="\\33\\46\\141\\64\\114";

should work since \ is special character
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why debugging a macro i s difficult 10 38
Problem to ASCII 1 196
IIS Log files on Exchange 2013 server 6 168
Windows Server 2008 R2: %HOMEDRIVE%%HOMEPATH% Incorrect 4 12
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question