Thread: why it is giving output 1 even though it exceeded octal range? Explain

  1. #1
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20

    why it is giving output 1 even though it exceeded octal range? Explain

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
     char x='\401';
     printf("%d",x);
     return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If your question is "what happens when I try to store a value that is too large to fit in the variable I am trying to put it into", the answer is "it gets cut off to fit". Otherwise, reload your question and try again.

  3. #3
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20
    If "it gets cut off to fit". can you explain how the 1 value is stored in x?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, that's what's left when you cut off the part that's too big.
    Code:
    your number -> 100000001
    what fits   ->  |______|

  5. #5
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20
    thanking you coder.......

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what will be the output and plz explain me
    By alekhya k in forum C Programming
    Replies: 6
    Last Post: 06-22-2011, 09:48 AM
  2. output screen isn't giving proper result
    By time4f5 in forum C Programming
    Replies: 11
    Last Post: 03-22-2011, 01:34 AM
  3. structure giving weird output
    By bluetxxth in forum C Programming
    Replies: 7
    Last Post: 02-14-2010, 11:44 PM
  4. help: please explain the output
    By soniclavier in forum C Programming
    Replies: 8
    Last Post: 12-07-2009, 12:35 PM
  5. Input & Output Explain?
    By 98dodgeneondohc in forum C Programming
    Replies: 5
    Last Post: 04-24-2005, 06:13 PM

Tags for this Thread