| Andym (11) | |
|
If I create an array in a function, I can do this: int main(); { int ConstantArray[3] = { 01, 02, 03}; cout << ConstantArray[1] return 0; } and it should print "02" to the screen, right? It seems that it is easy enough print the value within the same function but how do I get that info when I am trying to use it in a different function? This is what I tried: int GetValue(); { cout << ConstantArray[1] << endl; return 0; } Now how do I get the values from ConstantArray in the function GetValue? I've read tutorials but the info is just not clicking. | |
|
|
|
| Andym (11) | |
| Can anybody provide me with the piece of the puzzle I'm missing? | |
|
|
|
| fun2code (1063) | |||
You will need to pass the array to the function:
| |||
|
|
|||
| Jamil Shehzad (6) | |
|
Ok fun2code is also write that you should pass the array to getvalue function,...... its bit difficult concept if u r new to programming Just make your array global means declare it outside the main function. | |
|
|
|
| Andym (11) | |
|
Thank you! I made the array global and made the changes like fun2code had and it worked. Thanks so much for your help! That had me stumped last night!!! | |
|
|
|