1. Engineering
  2. Computer Science
  3. 2 write a function in c that takes a char...

Question: 2 write a function in c that takes a char...

Question details

(2) Write a function in C that takes a char * and an int argument and mallocs and initializes a StudentData ** int createRecord(int id, char *name, StudentData **record); Use this struct: typedef struct f char name [32]; int id; t StudentData; You malloc a new StudentData struct and then assign the id parameter to the id field in the struc and do strcpy() from the name parameter to the name field in the struct If the name is > 31 characters long, then return 1 and return a NULL through the record paramet otherwise, return 0 and return a pointer to the memory you mallocd through the record parameter. The C function for checking the length of a string is strlen(): strlen(hello) is 5 strlen() is 0 Call your function this way: int id - 17; char *name - Edsger Dijkstra; StudentData *record int rtnval createRecord(id, name, &record);

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution