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.

Void collectInt (char arr[80])
{
char arr[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;
}

but this function is not working. Pls help out!
Try for this one:

Void collectInt (char arr[80])
{
char arr1[80];
memset(arr1,'\0',80);
int j=0
for (int i=0; i<80 ; i++ )
{
if (arr[i] != "," || arr[i] != "$")
{
arr1[j] = arr[i];
j++;
}
else
continue;
}
cout << "The array collected is : "
for (int i=0; i<=j; i++ )
{
cout << i <<"\t" << arr1[i]<<"\n" << endl;
}
}

And if you want only certain character skeep other character by its ASCII value range
arr1 not defined in ur programme
And u should make a loop to change the values

if u want a code ask me
Topic archived. No new replies allowed.