Array passing around a class

hello, I have quite a large program I'm working on for class, In my program I have to put the contents of a text file into an array quite a few time, so to cut down on the code I'd like a function of my class to do the array creating, read contents of the file, fill the array with the contents then pass that to another function that searchs through it, i have a few different type of searchs to do on the array so this way will cut down in code alot. I think I'll have to use pointers, I understand there function but not the syntax for passing arrays around a program.

Kind regards
use std::vector. if you don't know how, do bother to learn (you could use the reference on this site). it's a very useful thing.
Ok thanks hamsterman I have looked at vectors but with me being a beginner and only started c++ a few months ago I dont fancy writing out my code again, but the next program i do for class I will spend the time to learn there function and use them in my program, i take it passing an array around in my current program isnt possible then, i was sure that it was.

thanks
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

void Function(int * ArrayPointer, int arraySize) 
{
    for(int i =0; i < arraySize; ++i)
    {
        ArrayPointer[i] = 0;
    }
}

int main ()
{ 
    int Data1[] = {10,11};

    Function(Data1, 2);

    std::cout << Data1[0] << " " <<  Data1[1] << std::endl;

    return 0;
}
Topic archived. No new replies allowed.