Question: I have a long list of names and i have to count number of times each name has come up. However the names are mixed with spaces. 

Here is the simple example

```
x <- c(" John D","John D ","John D")
table(x)
x
 John D  John D John D  
      1       1       1 

```

You can see because of the spaces it is recognizing as three different names. What i have to do is without loosing the Space between John and D, I have to remove remaining spaces.
Please help. Thanks.

Answer: 
```
    I have tried casting like
    arr[end] = (char) arr[start] ^ arr[end];

```

You are only casting the first `char` but not the other one thus giving you the result of `xor` in `integer/decimal value` of char not the `char value` itself.

**sample:**

instead you can wrap it in parenthesis and cast the result of the manipulation to char.

```
(char) (arr[start] ^ arr[end]);

```
In your code actually you are trying to insert an integer value in char type variable.  

When a xor operation is performed, the implicitly cast the value into integer type.  

```
arr[start] =  arr[start] ^ arr[end];

```

Consider the following:

```
char a = 'x';
char b = 'y';
char c = a ^ b;  //Error!

```

It is happening because compiler is converting character type `a` and `b` into an integer types, and then it perform the bitwise operation i.e. xor operation. the returned value will be of integer type.  

To make it work properly you have to explicitly cast the return type of the operation : 

```
char c = (char) a ^ b;

```

i.e. in your case :

```
arr[start] = (char) arr[start] ^ arr[end];

```