Thread: cannot understand this output - atoi

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    30

    cannot understand this output - atoi

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    #include<stdlib.h>
    
    int main(void)
    {
            char arr[50],a;
            char *ar;
            int x;
            
            printf("GETS --> ");
            ar = gets(arr);
    
            printf("PUTS --> ");
            puts(arr);
    
            sscanf(arr,"%c",&a);
            printf("PRINTF --> ");
            printf("%c\n",a);
    
            printf("ATOI --> ");
            x = (int) atoi(&a);
            printf("%d\n",x);
    
            getch();
    }
    OUTPUT

    GETS --> 2
    PUTS --> 2
    PRINTF --> 2
    ATOI --> 22 ? It should be 2
    Last edited by Salem; 10-02-2004 at 04:18 AM. Reason: CODE TAGS PEOPLE!!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM