Can anyone throw some light on this " void removem(char str[]) " function?
I am not able to trace this
if(a[str[i]] == -1)
{
a[str[i]] = i;
printf("%c",str[i]);
}
code.
funny, I could of sworn that's C code, besides, what are you trying to do?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void removem (char str[])
{
int i;
char a[256];
for (i = 0; i < 256; i++) //okay, set all 256 values of a[] to -1...
a[i] = -1;
for (i = 0; str[i] != '\0'; i++) //okay, loop through str until you reach the end...
{
if (a[str[i]] == -1) //if the value of a[] at index str[i] is -1, with str[i] returning a char, meaning if str[i] == '7' then if a['7'] == -1, '7' is ASCII is 55, so a[55] == -1.
{
a[str[i]] = i; //change a[55] to i
printf ("%c", str[i]); //print str? why? you haven't changed it
}
}
}
also
warning: array subscript has type 'char' [-Wchar-subscripts]|