Function that Selects characters in a string of char array...

This function is suppose to take an array of char type as argument, and select certain characters (integers and " . " ) in the array and ignore some characters ( "," and "$") contained in the array argument. It will then put the new strings of characters into another array.
<code>
Void collectInt (char arr[80])
{
char arr1[80];
int arrLen = strlen(arr);
for (int i=0; i<arrLen ; i++ )
{
if (arr[i] != "," || arr[i] != "$")
arr1[i] = arr[i];
else if (arr[i] == "," || arr[i] == "$")
arr1[i]= arr[i+1];
}
cout << "The array collected is : " << arr1 << endl;
}
</code>
but this function is not working. Pls help out!
Last edited on
This is wrong:
 
if (arr[i] != "," || arr[i] != "$")

Try this:

 
if (arr[i] != ',' || arr[i] != '$')

Thanks this helps but it inserts strange characters in place of the '$' and ','... Pls what else can be done
Topic archived. No new replies allowed.