I am trying to read a file name from the cmd line.
%./exec abc.txt
I can read in abc.txt as the argv[1] value. I need to make sure the file is a *.txt file.
I figured, finding the size of argv[1] would give me the number of chars in the file name, and checking the last 3 chars would give me the "txt" part. But sizeof(argv[1]) doesn't work. (Neither does sizeof(argv[1])/sizeof(char) ).
Any help would be appreciated.
%./exec abc.txt
I can read in abc.txt as the argv[1] value. I need to make sure the file is a *.txt file.
I figured, finding the size of argv[1] would give me the number of chars in the file name, and checking the last 3 chars would give me the "txt" part. But sizeof(argv[1]) doesn't work. (Neither does sizeof(argv[1])/sizeof(char) ).
Any help would be appreciated.