Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1039411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:05:46+00:00 2026-05-16T15:05:46+00:00

What I understand that hexadecimal numbers can be placed into string using \x .

  • 0

What I understand that hexadecimal numbers can be placed into string using \x. For example 0x41 0x42 can be placed in string as "\x41\x42".

char * ptr = "\x41\x42" ;
printf( "%s\n" , ptr ) // AB

\x is discarded and 41 is considered as a hex by the compiler.

But if I pass it to my program through command line arguments, it does not work.

    // test.c
    main( int argc , char * argv[] ) 
    {
       printf( "%s\n" , argv[1] ) ;
    }

$ gcc -o prog test.c
$ ./prog “\x41\x42”
\x41\x42
$ .prog \x41\x42
\x41\x42

What I expected was AB like in the example 1.
Why is it so? Why this method of representation does not work in case of command line arguments?
How can value in argv[1] which we know for sure is a hex string can be converted to hex number (without parsing, like done in the first example)?

Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:05:47+00:00Added an answer on May 16, 2026 at 3:05 pm

    \x41 is an internal C representation of a byte with a value of 41 (hex). When you compile this program then in the binary it WILL be 41h (just 1 byte – not \x41).
    When you pass \x41 from a command line it will be treated just as a string of 4 chars hence you see what you see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that we can set the various style attributes from code behind using
I understand that applications under the same domain name can talk to each other
I understand that there is a *.className selector since there can be multiple html
I understand that a const pointer can be declared a couple ways: const int
I understand that in the Air for IOS settings you can set the Resolution
I have a C++ script which involves string representations of would-be hexadecimal numbers. In
I have been following the msdn example that shows how to hash data using
understand that in App.Xaml.cs, I can create global variable and properties. How do I
I understand that: '\n' // literally the backslash character followed by the character for
I understand that JVM and CLR were designed as stack-based virtual machines. When JIT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.