The following program runs fine if 3 characters are given however as soon as 4 or more characters are given - the argv[1] becomes null. why?
#include <stdio.h>
int main(int args, char* argv[]){
char name[5];
printf("Enter yor name:");
fgets(name, 10, stdin); // delibrate
printf("name is: %s \n", name);
printf("argv is %s \n", argv[1]);
printf("Final Output - %s %s\n", argv[1] , name);
}
Invoking by - ./test hello
How and why does the difference in lengths of fgets and array produce this behavior?