How to find size of command line arguments?
Question about C , is `argv' 8 bytes? Asking because I'm trying to find the sizeof of my command line arguments. It's returning 8 bytes, but was expecting 1, since I read that all command line args are chars. Here's the code I wrote:
Code:
#include <stdio.h>
int main(int argc, char* argv[]) {
// User enters parameters for the argument
// Get the argument for argv[1], read in the key in that positon of the argument
printf("\nThis is the first argument after the program name: %s\n", argv[1]);
// Get the type
printf("\nThis is the size of the first argument: %ld\n", sizeof(argv[1]));
}
Here's my output:
This is the first argument after the program name: 5
This is the size of the first argument: 8
We still haven't covered pointers yet in my class, that's the next lesson