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 115 views
115 views asked Dec 29, 2021 by avibootz
2 answers 156 views
156 views asked Aug 18, 2017 by avibootz
1 answer 135 views
1 answer 80 views
80 views asked Dec 30, 2021 by avibootz
1 answer 114 views
2 answers 241 views
2 answers 231 views
231 views asked Jun 13, 2015 by avibootz
...