오류가있는 코드를 수정하려고하는데 알아낼 수없는 오류가 하나 남았습니다. 오류 : ''토큰 앞에 예상 기본 표현식이 무엇을 의미합니까? 잘못 배치 된 세미콜론과 변수 이름을 확인했지만 아무것도 찾을 수 없습니다. 여기에 내 코드가있다. 나는이 라인을 오류로 주석 처리했다 :'앞에'주 오류 의미
// countOnes.cpp
#include<iostream>
#include<cstdlib>
using namespace std;
void countOnes(int array[]); // Count the number of 1s in a given int array.
const int arraySize = 10;
int array[ arraySize ];
int countOne = 0;
int main()
{
for (int i = 0; i <= arraySize; i++)
{
array[ i ] = rand() % 3; // Fill array with 0, 1 or 2 randomly
cout << array[ i ] << " ";
}
countOnes(array[], arraySize); //ERROR
cout << "\n The number of 1s in the array: " << countOne;
return 0;
}
void countOnes(int array[], int arraySize)
{
for (int i = 0; i <= arraySize; i++)
if (array[ i ] == 1)
countOne = countOne + 1;
return;
}
C++에서'std :: vector' 사용을 고려해야합니다. – balki
런타임 오류가 아니라 컴파일러 오류 – balki