1// Use malloc to allocate memory
2ptr = (castType*) malloc(size);
3int *exampl = (int*) malloc(sizeof(int));
4// Use calloc to allocate and inizialize n contiguous blocks of memory
5ptr = (castType*) calloc(n, size);
6char *exampl = (char*) calloc(20, sizeof(char));
1// Only 5 characters printed. When using %.*s, add a value before your string variable to specify the length.
2printf("Here are the first 5 characters: %.*s\n", 5, mystr); //5 here refers to # of characters
1// Only 5 characters printed
2const char * mystr = "This string is definitely longer than what we want to print.";
3printf("Here are first 5 chars only: %.5s\n", mystr);