what is the output?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saraswathi v
    New Member
    • Jan 2011
    • 3

    what is the output?

    Code:
    char ch="name";printf("%d%c",53815);
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    although the program may compile and run it has a couple of errors
    Code:
    char ch="name";
    ch is a char (a byte sized int)and you are attempting to initialise it with the address of a string (a pointer) so you would get a compiler message such as (from gcc)
    Code:
    warning: initialization makes integer from pointer without a cast
    the printf statement
    Code:
    printf("%d%c",53815);
    has two conversion specifications %d and %c but only one parameter following. The %d would print 53815 as an int and the %c would pick whatever is next on the stack and print it as a char.

    Comment

    Working...