#include <stdio.h>
#include <stdlib.h>
typedef struct two_string
{
char * first;
char * second;
}ts;
void getmem(ts * t, unsigned first_n, unsigned second_n)
{
t->first = (char *)malloc(sizeof(char) * first_n + 1);
t->second = (char *)malloc(sizeof(char)* second_n +1);
}
void free_ts(ts * t)
{
free(t->first);
free(t->second);
}
int main()
{
ts pair_string;
getmem(&pair_string,10,10);
scanf("%s%s",pair_string.first, pair_string.second);
printf("%s\n%s\n",pair_string.first, pair_string.second);
free_ts(&pair_string);
pair_string = (ts){"hello","world"};
puts(pair_string.first);
puts(pair_string.second);
return 0;
}
|