#include #include #include void main(int argc, char ** argv){ printf("argc = %d\n", argc); for(int i = 0; i < argc; i++){ printf("argv[%d] = %s\n", i, argv[i]); } printf("Here is where things are located in argv:\n"); for(int i = 0; i < argc; i++){ printf("argv[%d] is at location 0x%lx\n", i, argv[i]); } printf("Beginning print without respecting null terminators\n"); for(int i = 0; i < 100; i++){ char next = argv[0][i]; if(!next) next = '_'; printf("%c", next); } printf("\n"); // This is a shallow copy char* firstword = argv[1]; printf("firstword = %s\n", firstword); argv[1][1] = 0; printf("firstword = %s\n", firstword); // This will be a deep copy char* secondword = malloc(strlen(argv[2])); strcpy(secondword, argv[2]); printf("secondword = %s\n", secondword); argv[2][1] = 0; printf("secondword = %s\n", secondword); free(secondword); // It would have been freed at the end of main anyway }