Struct not printing properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EVAS
    New Member
    • Nov 2007
    • 8

    #1

    Struct not printing properly

    ......
    [code=cpp]
    typedef struct user {
    char login[LOGIN_SIZE];
    } user;

    typedef struct mail {
    user sender;
    user receiver;
    char * body;
    struct mail * next;
    } mail;

    user users[3] = {"AAA","BBB","C CC"};
    mail mail1;
    mail1.sender= users[0];
    printf("SENDER %s",mail1.sende r);
    [/code]
    It prints "SENDER" and not the mail1.sender.if i make the printf like this:
    printf("SENDER %c",mail1.sende r); it prints SENDER A....What shall I do?
    Last edited by sicarie; Nov 19 '07, 01:56 PM. Reason: Code tags and shouting annoys me
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    mail1.sender is of type user...but you are using the %s output modifier. Should you be using that with mail1.sender.lo gin, which is of type char[]?

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      EVAS-

      Please check your Private Messages, accessible via the PMs link in the top right corner of the page

      Thanks

      Comment

      Working...