How to use typedef to define a struct in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

typedef struct user
{
    char email[30];
    int password;
} login;

int main(int argc, char **argv) 
{ 
    login dan;
    
    strcpy(dan.email, "dan@email.com");
    dan.password = 19108;
    
    printf("%s\n", dan.email);
    printf("%d\n", dan.password);
    
    return(0);
}

/*
run:

dan@email.com
19108

*/

 



answered Jun 11, 2015 by avibootz

Related questions

1 answer 270 views
270 views asked Dec 29, 2021 by avibootz
2 answers 314 views
314 views asked Aug 18, 2017 by avibootz
1 answer 273 views
1 answer 239 views
239 views asked Dec 30, 2021 by avibootz
1 answer 259 views
2 answers 419 views
2 answers 433 views
433 views asked Jun 13, 2015 by avibootz
...