Answers for "struct function in c"

C
27

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;
    //accessing members of the struct
    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;
}
Posted by: Guest on June-04-2020
1

structure and function in c

#include <stdio.h>
#include <string.h>
 
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 n", record->id);
          printf(" Name is: %s n", record->name);
          printf(" Percentage is: %f n", record->percentage);
}
Posted by: Guest on July-27-2020
0

struct main function c in unix

/* main.c */
int main(int argc, char *argv[]) {

}
Posted by: Guest on November-26-2020
0

function inside struct c

typedef struct client_t client_t, *pno;
struct client_t
{
        pid_t pid;
        char password[TAM_MAX]; // -> 50 chars
        pno next;

        pno (*AddClient)(client_t *);  <-- pointer to function    
};

pno client_t_AddClient(client_t *self) { /* code */ } <-- function

int main()
{

    client_t client;
    client.AddClient = client_t_AddClient; // probably really done in some init fn

    //code ..

    client.AddClient(&client);

}
Posted by: Guest on May-05-2021
0

structure and function in c

#include <stdio.h>
#include <string.h>
 
struct student 
{
            int id;
            char name[20];
            float percentage;
};
struct student record; // Global declaration of structure
 
void structure_demo();
 
int main() 
{
            record.id=1;
            strcpy(record.name, "Raju");
            record.percentage = 86.5;
 
            structure_demo();
            return 0;
}
 
void structure_demo()
{
            printf(" Id is: %d n", record.id);
            printf(" Name is: %s n", record.name);
            printf(" Percentage is: %f n", record.percentage);
}
Posted by: Guest on July-27-2020
0

struct in c

// dichiarazione della struct
struct libro
{
  char titolo[100];
  char autore[50];
  int anno_pubblicazione;
  float prezzo;
};

//dichiarazione dell'istanza biblio
struct libro biblio;
Posted by: Guest on April-19-2021

Code answers related to "C"

Browse Popular Code Answers by Language