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 186 views
186 views asked Dec 29, 2021 by avibootz
2 answers 203 views
203 views asked Aug 18, 2017 by avibootz
1 answer 184 views
1 answer 151 views
151 views asked Dec 30, 2021 by avibootz
1 answer 164 views
2 answers 313 views
2 answers 291 views
291 views asked Jun 13, 2015 by avibootz
...