Solved

Escape character in c program (linux op)

Posted on 2003-11-21
5
1,231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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.
Suggested Courses

751 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