I just recently started programming in C.
I'm running into problems with Malloc. It seems like malloc doesn't do anything with my string?
I have the following code:
Why can I put a string in that is larger dan 5 bytes?Code:char *s; s = malloc( 5 * sizeof(char)); strcpy(s, "123451234567890876432123456789678"); or s = "123456678"; printf("String is: %s", s);
I've tried many different ways and everytime I reserve a few bytes I can make the string larger.
Maybe i'm using things wrong but i would appreciate it if someone can explain to me why this works...