I am trying to create a simple loop to read in an array of characters and print back the array without any excessive white-space.
I am having issues with my loop and was hoping to get some assistance.
for(int i=0;i<ARR_SIZE;++i) //Initialize loop
{
if(isspace(arr[i])&&isspace(arr[i+1]) //If check for double whitespace
{arr[i+1] = arr[i+2];} //If detected, move the character after the whitespace (+2) to (+1)
}
This does remove the double white space, but I'm having trouble with the logic as to what I'd do to copy all the other characters in.
I.e. current if I put in "t__est" I'd get "t_eest".
Its a fairly simple question, but I think I'm either thinking too much about it, or missing some simple logical step.
Any advice would be appreciated.