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 9267341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:31:44+00:00 2026-06-18T14:31:44+00:00

I have been trying to understand the printf functionality for octal numbers. If I

  • 0

I have been trying to understand the printf functionality for octal numbers.

If I write the code as:

int main()
{
  char *s = "\123";
  printf("%s", s);
}

It gives me an output as S which actually is correct since ASCII of S is 123 in octal.

But how does the compiler identify the sequence of numbers to convert from octal? For example:

char *s = "\123456"

would give an output as S456.

Is it that it takes maximum three numbers for octal conversion?

Is there a maximum limit within which the octal should be given (the maximum three-digit octal number would be 777).

Now since there are max 255 ASCII characters (octal 377) then when I try to print 777 it prints a typical � ASCII character, which is presume may be since there is no such ASCII assigned to this number.
Also is this functionality a compiler/OS dependent?

  • 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-06-18T14:31:45+00:00Added an answer on June 18, 2026 at 2:31 pm
    1. Yes. Three digits are the maximum for an octal character literal. From the spec 6.4.4.4 Character constants:

      octal-escape-sequence:
      \ octal-digit
      \ octal-digit octal-digit
      \ octal-digit octal-digit octal-digit

      hexadecimal-escape-sequence:
      \x hexadecimal-digit
      hexadecimal-escape-sequence hexadecimal-digit

    2. The maximum octal escape sequence is \777 as you mention. There is no maximum limit for a hexadecimal escape sequence as you can see from the spec quote above.

    3. There are only 128 ASCII characters (0-127). That means you can use octal \000 through \177 for ASCII. If you use a different character set, you might be able to go to \377 in an 8-bit char, and all the way to \777 (or higher, using hex escape sequences) for a wchar_t. The spec says:

      The value of an octal or hexadecimal escape sequence shall be in the range of representable values for the type unsigned char for an integer character constant, or the unsigned type corresponding to wchar_t for a wide character constant.

      On most machines, unsigned char is an 8-bit type, limiting your octal escape sequence to \377 in that context and the hex sequence to \xff. In the case of a 32-bit wchar_t context, the hex sequence could be as high as \xffffffff.

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

Sidebar

Related Questions

I have been trying to understand of this following C-program: #include <stdio.h> int arr[]
I'm trying to write more efficient code in my scripts and have been implementing
I have been trying to understand the way ActionScript's events are implemented, but I'm
okay i have been trying to understand this for hours i am learning VB
So, I have been trying to understand Socket.io lately, but I am not a
I have been trying to get some basic dynamic code compilation working using the
I have been trying to understand the use of primitives in Java and C#
I have been trying to understand the follwing program. On server side the following
I have been trying to understand the basics of MapReduce in MongoDB and even
I have been trying to understand the concepts of Maven and I find it

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.