Write a function that removes all duplicate spaces from a sentence. Your program should ensure that only one space exists between words

/* We can remove duplicates by checking each character and having a space count. But here we are doing it using the string library function strtok

*/

#include <stdio.h>

#include <string.h>

int main(){

char input[100];

char output[100];

char temp[100];

char *p;

printf(“\nPlease enter a sentence :”);

gets(input);

strcpy(temp, input);

strcpy(output,””);

p = strtok(temp, ” “);

while ( p != NULL ){

strcat(output,p);

strcat(output,” “);

printf(“%s\n”, p);

p = strtok(NULL, ” “);

}

printf(“%s\n”, input);

printf(“%s\n”, output);

printf(“%d\n”, strlen(output));

return 0;

}