I'm trying to pass a string as a pointer to another function and getting some errors. I need a template array that always get's reset after I've made changes and published the changes, so I was going to use a pointer passed to another function. Here's an example of what I'm trying to do.
#include <iostream> //// you had stdio.h
#include <string>
usingnamespace std;
void reset_myString( string* szTemp ); //// array size not needed
int main ()
{
int x;
string szTemp[6]; //// must be 6 to use elements 0 through 5
reset_myString( szTemp ); //// don't need the array size here
for ( x = 0; x <= 5; x++ ) { cout << szTemp[x] << endl; }
szTemp[3] = "BREAK";
for ( x = 0; x <= 5; x++ ) { cout << szTemp[x] << endl; }
reset_myString( szTemp ); //// same as above
for ( x = 0; x <= 5; x++ ) { cout << szTemp[x] << endl; }
return 0;
}
void reset_myString( string *szTemp )
{
for ( int x = 0; x <= 5; x++ )
szTemp[x].erase();
szTemp[0] = "abc";
szTemp[1] = "def";
szTemp[2] = "ghi";
szTemp[3] = "jkl";
szTemp[4] = "mno";
szTemp[5] = "pqr";
}