Thread: what exactlly these values returns?

  1. #1
    Join Date
    Oct 2009

    what exactlly these values returns?

    struct s
    struct s gs; 
    int main()
    struct s s1; 
    printf("%u \n",gs);
    printf("%u \n",s1);
    printf("%u \n",&gs);
    printf("%u \n",&s1);
    return 0;
    output :3214811820

    can any one give exactlly s1,gs,&s1,&gs returns?

  2. #2
    Registered User
    Join Date
    Mar 2009
    What's wrong with the answer you got here:

    wt is output of s1, &s1

  3. #3
    Registered User
    Join Date
    Aug 2006
    What are you doing? The first two printf's are meaningless garbage.
    The second two are the addresses that your empty structures are at.

    Who comes up with these questions?
    You can't just use non-existant data in an empty structure as if it were a standard type.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    The first two are undefined because print expects an unsigned integer, and not a struct s. Whatever nonsensical output you get (if not a crash) is meaningless, because it isn't supposed to be "anything".
    &s1 and &gs returns the addresses in memory where the two instances of the struct are located. They should be printed using %p, not %u, however, since the later results in undefined behavior.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-19-2008, 02:36 PM
  2. IRC-type logger with files based on three values
    By Lechx in forum C Programming
    Replies: 4
    Last Post: 08-27-2008, 04:42 PM
  3. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  4. sizeof(array) returns differnt values for same array?
    By Diamonds in forum C++ Programming
    Replies: 6
    Last Post: 02-02-2003, 04:27 PM
  5. unsigned char vs signed char and range of values
    By Silvercord in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2003, 01:30 PM