Solved

Escape character in c program (linux op)

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert image to byte array 8 203
C++ vs C compilers 13 159
valid enum? 6 74
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 34
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

803 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