Example
int
main(
int
argc,
char
* argv[])
{
int
index = 2;
cout << argv[index];
return
0;
}
Solution
Make sure the value of the index variable is within the bounds of the array before using it.
int
main(
int
argc,
char
* argv[])
{
int
index = 2;
if
( index>=0 && index< argc){
cout << argv[index];
}
return
0;
}