I am a beginner in C++ so it's more than likely that my problem is extremely easy to solve. My problem is that I am trying to declare an array in my header file, but i can`t acces it in my main.cpp unit. The error message that keeps printing is:"initializing: cannot convert from 'int' to 'int [6]'
This is the code in my header file:
#pragma once
extern int Guess[6] = 0;
void Input(){
std::cout << "Please enter your 6 numbers in the range of 1-49 line by line:" << std::endl;
for (int i = 0; i < 6; i++){
std::cin >> Guess[i];
for (int i1 = 0; i1 < 6; i1++){
if (Guess[i1] > 50){
std::cout << "Your number is not in the range!!! Try again please:" << std::endl;
Guess[i1] = 0;
std::cin >> Guess[1];
}
}
}
std::cout << Guess[0] << std::endl;
std::cout << Guess[1] << std::endl;
std::cout << Guess[2] << std::endl;
std::cout << Guess[3] << std::endl;
std::cout << Guess[4] << std::endl;
std::cout << Guess[5] << std::endl;
}
And this is the code in main.cpp
:
#include "stdafx.h"
#include <iostream>
#include "Input.h"
int main(){
int Guess[6];
Input();
return 0;
}
Thanks for any potential help.