#include <iostream>
usingnamespace std;
void delete_repeats(char a[],int& sizes);
void get_size(int& sizes);
int main()
{
int sizes;
char a[sizes];
get_size(sizes);
delete_repeats(a,sizes);
return 0;
}
void delete_repeats(char a[],int& sizes)
{
cout << "Enter " << sizes << " characters:\n";
for (int i = 0; i < sizes; i++)
cin >> a[i];
}
void get_size(int& sizes)
{
cout << " Enter how many characters do you want to enter.\n";
cin >> sizes;
}
The out put screen is
Process returned -1073741571 (0xC00000FD) execution time : 0.040 s
Press any key to continue.
For the main part, I added cout << "1"; after char, and still nothing comes out,
but when I add it after between int and char, it shows up. Does it mean the program stop before char a[sizes]?
So use arrays, but to statically allocate an array the size must be a compile time constant. Just create a large array and make sure the number you user enters for the size is actually equal to or smaller than your array size. If they try to enter a larger number tell them the maximum size and make them re-enter the number until it is correct, or terminate the program.