Hello everyone, I am trying to make an array of size "N" for a school homework assignment involving sorting large arrays. My teacher says to use the command line to get the value n.
I asked about it and they recommended that argv[1] will have the value I want.
my problem is that every time I try to access element 1 of char * argv[] my program completely crashes.
here's how I'm going about it:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <stdlib.h>
using std::cout;
int main(int argc, char * argv[])
{
int n;
n = atoi(argv[1]); // this is where it crashes!
}
Anybody know why this happens and how I can fix it? I can't start my project until I can make an array of size n! Thanks in advance.