Solved

Escape character in c program (linux op)

Posted on 2003-11-21
5
1,221 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now