这是我的代码:
int main(){
long userInput;
long placeArray[userInput +1];
long divisionPlace, modPlace;
long number = userInput;
long two = 2;
cout << "enter: ";
cin >> userInput;
for (int i = 1; i < userInput; i++) {
divisionPlace = number / two;
modPlace = number % two;
placeArray[number - i ] = modPlace;
}
for (int i = 0; i < userInput; i++) {
cout << placeArray[i] << " ";
}
cout <<endl;
return 0;
}
有人可以指出我在代码中的错误,为什么我处理错误的内存?