Solved

Escape character in c program (linux op)

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

627 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