struct -> c code example
Example 1: struct in C
#include<stdio.h>
#include<string.h>
struct Student{
long int rollNo;
int age;
char name[50];
int totalMarks;
};
int main(){
struct Student s1;
s1.rollNo = 1232234643;
s1.age = 10;
char s[]="Jonathan";
strcpy(s1.name,s);
s1.totalMarks = 450;
printf("RollNumber: %d \nName: %s \nTotal Marks: %d",s1.rollNo,s1.name,s1.totalMarks);
return 0;
}
Example 2: struct
#include <stdio.h>
main () {
struct person {
char[] name;
int age;
}
}
Example 3: struct in c
struct libro
{
char titolo[100];
char autore[50];
int anno_pubblicazione;
float prezzo;
};
struct libro biblio;