Q:

Homework: Why is argv[2] defined?

I am getting a weird string for my argv[2], when I run this program without any inputs. Why isn't argv[2] undefined? TERM_PROGRAM=Apple_T <- That's what I get. I'm wondering if this has something to do with running it on a mac?
if(argv[2]) {
    sscanf(argv[2], "%lf", &argWind);
    sscanf(argv[2], "%20s",  str);
    sprintf(str2, "%lf", argWind);
    printf("String: %s, %lf", str, argWind);
    int len;
    len = strlen(str);
    str2[len] = '\0';

    if(strcmp(str, str2)){
        printf("\nError: you entered a non-numeric entry for wind speed\n");
        return 0;
    }
} 

A:

Undefined behaviour is undefined. Anything could happen. In this case it looks like you're running past argv and into the third (less well known and certainly nonstandard) parameter of main, commonly called envp. Relevant link.

