Cool, What about if we take it one step further and have this: int main() { string mystring[] = {"ASD","asdf"}; int i; i = myfunc(mystring[]); cout << i; return 1; } int myfunc(string mystring[]) { int i; i = sizeof(mystring) / sizeof(mystring[0]; return i; } I get two different results when using the sizeof() in myfunc and sizeof in main.... Do I need to pass a pointer to the string??
M
mrspam
@mrspam
Posts
-
string arrays in c++ -
string arrays in c++Consider the following: string mystring[] = {"Hello","World"}; How do I find how many elements my array of has? If for example I wanted to loop through the array and count the elements that had the letter 'L' or 'l' in them. displaying something like: element 1: 2 element 2: 1 My main focus here is how do I find out the number if elements in a given array. Thanks in advance for your help.