Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 #include 2 #include 3 #include s struct _string_pair t f 6 char * str1; char * str2; 9 typedef struct _string pair t string
1 #include 2 #include 3 #include s struct _string_pair t f 6 char * str1; char * str2; 9 typedef struct _string pair t string pair t; 10 u int main(void) f 12 char* line= NULL size t sz; 13 14 string pair t ** array; 15 int count=0; 16 while (getline (&line , &sz, stdin) >= 0) { 17 18 19 20 21 array = realloc (array, (count+1) * sizeof (*array)); array [count] = malloc (sizeof (array [count])); array [count]->str1 - strdup(line); char * p = strchr (array [count]->str 1, ,-) ; if (p != NULL) { array [count]->str2 = strdup(strchr (line , -') + 1); 23 else 25 array [count]->str2 NULL; = 26 28 counttt; 29 30 for (int i-0; i str2); printf ("%s %s ", array [1]->str1, free(array[i]->stri); free(array[i]->str2); 31 34 as free (array); 36return EXIT SUCCESS
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started