|
|
back to boardRuntime Error(access Violtion) HELP!! #include <iostream> #include <string> using namespace std; int main() { string a[3000]; int n; int m; cin >> n; cin >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } int j = m; for (int i = 0; i < 10; i++) { cout << a[j]; j++; if (j == n ) { j = 0; } } cout << endl; return 0; } Re: Runtime Error(access Violtion) HELP!! add ""cout<<flush;"" in diffrent places and see if it works(sometimes solves the error) Re: Runtime Error(access Violtion) HELP!! string a[3000]; Hmm. It's really funny to use string array for containing int values. Edited by author 13.04.2014 14:08 Re: Runtime Error(access Violtion) HELP!! 1 ≤ M ≤ 32767. and you are trying to print a[j] which j >= m Re: Runtime Error(access Violtion) HELP!! m can be above n; m can be above a length. To put big arrays on stack is a bad idea. a should be dynamic array or vector. |
|
|