#include <stdio.h>
#include <stdlib.h>
main()
{
char *s1 = NULL;
size_t len = 0;
char *s2;
s2 = (char *)malloc(getline (&s1, &len, stdin) + 1);
printf("string 1: %s\n", s1);
while(*s2++ = *s1++)
;
printf("string 2: %s\n", s2);
free(s1);
free(s2);
}
$ ./a.out
asdf
string 1: asdf
string 2:
Segmentation fault (core dumped)
Что не так?
Гуглил malloc, getline, ssize_t, size_t. Светлее в голове не стало.