C noob here. What does it matter what argument I give malloc when I can pass whatever size string to it later?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
    char *str;
    str = malloc(1*sizeof(char));
    strcpy(str, "abcd");
    printf(str);
    printf("\n");
    return 0;
}
This works fine. I would have thought I wouldn't be able to store more than 1 char in str from my understanding of what malloc is supposed to be.
 
    