Hello all,
i have two functions. one trims the right and left sides of a char* array - strTrim(char* str). the other takes a variable length parameter list and calls strTrim w/ each char* array in the list.
bool nullChecker(int numOfStrs, ...){
int i = 0;
va_list marker;
va_start( marker, numOfStrs );
while( i++ < numOfStrs )
{
char* currStr = va_arg(marker, char*);
cout << currStr << endl;
if(currStr == NULL || *currStr == NULL ||
*(currStr = strTrim(currStr)) == NULL)
*currStr = NULL;
cout << "currStr :" << currStr << ":" << endl;
}
va_end( marker );
return true;
}
as long as i call strTrim directly from main, my char* arrays get changed because they are passed by reference. but when i call nullChecker from main, my char* arrays dont get changed ... if i check the arrays after nullChecker, they are the original arrays w/ the spaces.
am i messing up my pointers or is it possible to do what im trying to do?
thanks
txjump
i have two functions. one trims the right and left sides of a char* array - strTrim(char* str). the other takes a variable length parameter list and calls strTrim w/ each char* array in the list.
bool nullChecker(int numOfStrs, ...){
int i = 0;
va_list marker;
va_start( marker, numOfStrs );
while( i++ < numOfStrs )
{
char* currStr = va_arg(marker, char*);
cout << currStr << endl;
if(currStr == NULL || *currStr == NULL ||
*(currStr = strTrim(currStr)) == NULL)
*currStr = NULL;
cout << "currStr :" << currStr << ":" << endl;
}
va_end( marker );
return true;
}
as long as i call strTrim directly from main, my char* arrays get changed because they are passed by reference. but when i call nullChecker from main, my char* arrays dont get changed ... if i check the arrays after nullChecker, they are the original arrays w/ the spaces.
am i messing up my pointers or is it possible to do what im trying to do?
thanks
txjump