#include "stdafx.h"
#include <iomanip>
#include <ostream>
#include <fstream>
using namespace std;
void FillArray(int x[ ], const int Size);
void PrintArray(int x[ ], const int Size);
int main()
{
const int SizeArray = 10;
int A[SizeArray] = {0};
FillArray (A, SizeArray);
PrintAray (A, SizeArray);
return 0;
}
void FillArray (int x[ ], const int Size)
{
for( int i = 0; i < Size; i++);
{
cout << endl << "enter an integer"; //cout undeclared here
cin >> x[i]; //cin and i undeclared here
}
The “cout”, “cin”, and “i” all get the error “error C2065: 'cin' : undeclared identifier“. I have no idea how to fix them. I have to have three functions: Main, fill array, and print array. Help is appreciated.
1) You have to
include <iostream>, for the definitions ofcinandcout.2) You have a semicolon after your for loop, which will prevent it from repeating. It also makes the scope of
iend, so you can’t use it in the braces either.3) Don’t use
using namespacewithout good reason.4) Don’t use pictures of code.
5) Always give full error messages. In Visual Studio that’s in the “Output Window” not the “Error Window”. For instance “identifier is unidentified” is not an error message.
6) Reduce your code to a SSCCE before posting, always. 95% of the time you’ll find the problem yourself.