Hello people, im new on this forum, and also new to programming.
I have a problem i have spent some hours trying to figure out, but i cant seem to get it.
I have written this code to illustrate my problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
using namespace std;
void test();
int main(){
//calling my function
test();
//declearing my array from test()
int x[2];
//i use cout to check if i really have a copy of x[]
cout << x[0] << x[1];
//output: i have obviously not
void test(){
int x[2] = {1,2};
}
|
Comment:
This just illustrates my problem. What im actually working on is this:
i have created a function which generates an array of size 4, with 4 random letters in. I.e. array1[4] ={A B B F}
I have also created a function which allow input so that one can guess which letters are generated. I.e. array2[4] = {A B C D}
And then i have to TRANSFER these arrays over in a third function so that i can check how many letters are guessed correctly. In this case the answer is 2.
So: how can i use an array generated in functionA, in functionB ?
Thank you very much for your help.
-cid