• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

C language - how to ignore special characters.


I have a value is dynamic which returned from server, value looks like: "\x001\x003\x008\x008"

I want to captured that value then send back to the server but I don't know how to process.

Because the value is dynamic so I cannot set fixed like: "\\x001\\x003\\x008\\x008"

Does anyone have idea how to replace or escape the special character "\" in C language?

  • 2
2 Solutions
The way to represent the '\' character in C is '\\' (i.e. two slashes in source code = a single slash at run-time).
I wonder if this might not help (since I'm not sure how much you do and don't know about the esc character).

The Escape character only hold meaning in source code.  The compiler will read the escape and interpret it properly.

Part of what you are showing is the combined escape sequence of \x which means you are attempting to represent a character with a hex number.  If you replace the x with a 0 then you are attempting to represent a character with octal numbers.

So the following are three ways to represent a '\' in source code:
'\\' == '0134' == '\x5C'      //This is a logical TRUE statement.

Here is another example that is more mundane:
'A' == '\0101' == '\x41'
value looks like: "\x001\x003\x008\x008"

do you see the above in the debugger? or in a log file? Is it a string (text) enclosed by double quote characters "" ? as HooKooDooKu explained the string looks like a textual output of a binary byte array

unsigned char bytes[4] = { 0x1, 0x3, 0x8, 0x8 };

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now