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 176 views
176 views asked Dec 29, 2021 by avibootz
2 answers 199 views
199 views asked Aug 18, 2017 by avibootz
1 answer 175 views
1 answer 140 views
140 views asked Dec 30, 2021 by avibootz
1 answer 155 views
2 answers 297 views
2 answers 282 views
282 views asked Jun 13, 2015 by avibootz
...