title: “CheetSheet”
date: 2021-07-21T08:08:15
slug: cheetsheet-2
char name[] = "Thomas";
bool active = true;
double workingdays = {1,4,6}
Define Structure with Alias and access it:
typedef struct Point{
int x;
int y;
} Point;
Point one, two;
one.x=5;
one.y=7;
Nested Structure:
typedef struct Point{
int x;
int y;
} Point
typedef struct Location{
int number;
Point p;
} Location
Passing struct to function
#include
#include
struct student
{
int id;
char name[20];
float percentage;
};
void func(struct student \*record);
int main()
{
struct student record;
record.id=1;
strcpy(record.name, "Raju");
record.percentage = 86.5;
func(&record);
return 0;
}
void func(struct student \*record)
{
printf(" Id is: %d
", record->id);
printf(" Name is: %s
", record->name);
printf(" Percentage is: %f
", record->percentage);
}