While creating strjoin I noticed a strange phenomenon. When outputting a value strs in function strjoin()
These results were printed
123
Why?
#include <stdio.h>
#include <stdlib.h>
char *strjoin(int size, char **strs, char *sep)
{
char *new;
if (!(new = malloc(sizeof(char) * size)))
return (NULL);
printf("%s", strs[1]);
return (NULL);
}
#include <unistd.h>
int main(void)
{
char* b[4] = {"123", "456", "789", "245"};
char *p;
int i = 0;
int size = 5;
char a[4] = {',', 'a', 'b', '\0'};
p = *b;
strjoin(5, &p, a);
}