I'm writing a program in C that receives two strings as input from the user on the command line. I know that when you use
int main(int argc, char *argv[])
it creates a pointer to the array that stores both arguments as argv[1] and argv[2]. Say the user inputs "hello" on the command line, and I want to access the individual characters in "hello", how can I do so if argv[1] gives me the whole string rather than individual characters?
argv[x](for any validx) is a string. You access individual elements of that like you do for any other string. You have encountered array of arrays before? Treatargvlike an array of arrays.argvis not a 2D array.argvis a pointer, a pointer to achar *.