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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,946 questions

51,887 answers

573 users

How to structure pointer in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

struct user {
	char name[32];
	long id;
	float salary;
};
 
int main(void)
{
 	struct user u, *p;

	p = &u;
 
	strcpy(p->name, "r2d2");
    p->id = 9089387;
    p->salary = 12500;

    printf("Name: %s\nid: %ld\nsalary: %.2f", p->name, p->id, p->salary);
  
	return 0;
}





/*
run:

Name: r2d2
id: 9089387
salary: 12500.00

*/

 



answered Aug 23, 2021 by avibootz

Related questions

1 answer 77 views
77 views asked Jun 7, 2024 by avibootz
2 answers 134 views
1 answer 153 views
1 answer 115 views
1 answer 140 views
140 views asked Aug 22, 2021 by avibootz
2 answers 232 views
...