can anyone help me explain this code?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can anyone help me explain this code??

#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int num; char *info; } record; int main() { record *recs; int num_recs = 2; int k; char str[ ] = "This is information"; recs = calloc(num_recs, sizeof(record)); if (recs != NULL) { for (k = 0; k < num_recs; k++) { (recs+k)->num = k; (recs+k)->info = malloc(sizeof(str)); strcpy((recs+k)->info, str); } } for (k = 0; k < num_recs; k++) { printf("%d\t%s\n", (recs+k)->num, (recs+k)->info); } return 0; }

6th Apr 2021, 1:33 PM
RAJESH
1 Answer
- 1
Martin Taylor the program is in the practice session of C programming
6th Apr 2021, 2:20 PM
RAJESH