Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,037 questions

40,788 answers

573 users

How to use typedef struct in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
 
typedef struct USERs {
   char name[32];
   int age; 
   float salary; 
} USER;
 
int main(void) {

   USER user;
 
   strcpy(user.name, "R2D2");
   user.age = 60;
   user.salary = 15980;
 
   printf("user.name : %s\n", user.name);
   printf("user.age : %d\n", user.age);
   printf("user.salary : %.2f\n", user.salary);

   return 0;
}




/*
run:

user.name : R2D2
user.age : 60
user.salary : 15980.00

*/

 





answered Dec 29, 2021 by avibootz

Related questions

2 answers 101 views
101 views asked Aug 18, 2017 by avibootz
1 answer 98 views
98 views asked Jun 11, 2015 by avibootz
1 answer 39 views
39 views asked Dec 30, 2021 by avibootz
1 answer 59 views
59 views asked May 7, 2021 by avibootz
3 answers 216 views
...