quick question Arrays and pointers!

i have an array created in one class and passed as a pointer to another classes function parameter.

I am having trouble referencing the length of the array
and the length of the string in the array? If anyone has any suggestions Please let me know.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
string input::function(string SS, string *del, int l)

for (int i = 0; i < (length of the array); i++)
    {
        pos = userInput.find(del[i]);
        if (pos != string::npos )
        break;
    }
    if (pos == string::npos)
    {
        cout << "\nInvalid Input\n";
        userInput.clear();
        return userInput;
    }
    else
    lastPos = userInput.find_first_not_of((length of the actual string in the del[] array found at pos), pos);
You must explicitly pass the length of the array to input::function().
ok thankyou. i have realized that but i was also wondering if i am even passing the array correctly? I am passing it a pointer to an array but was thinking that the function should be asking for an Array

string input::function(string SS, string *del, int l)
VS
string input::function(string SS, string del[], int l)

If i ask for an array can i still pass the pointer when i call the function like

1
2
3
4
mySorI[] = {SIQ}
string * mySOrIptr;

newInput.function(input, mySOrIptr, sizeof(mySorI));
Topic archived. No new replies allowed.