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,094 questions

40,775 answers

573 users

How to use typedef to declaring struct in C

2 Answers

0 votes
#include <stdio.h>

typedef struct Person {
    int age;
} Person;


int main(void)
{
    Person p;
    
    p.age = 50;

    printf("p.age = %d", p.age); 

    return 0;
}
    
/*
run:
 
p.age = 50
   
*/

 





answered Aug 18, 2017 by avibootz
0 votes
#include <stdio.h>

typedef struct {
    int age;
} Person;


int main(void)
{
    Person p;
    
    p.age = 40;

    printf("p.age = %d", p.age); 

    return 0;
}
    
/*
run:
 
p.age = 40
   
*/

 





answered Aug 18, 2017 by avibootz

Related questions

2 answers 120 views
120 views asked Aug 18, 2017 by avibootz
1 answer 60 views
60 views asked Dec 29, 2021 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 58 views
58 views asked May 7, 2021 by avibootz
...