I have read a few lines of text into an array of C-strings. The lines have an arbitrary number of tab or space-delimited columns, and I am trying to figure out how to remove
The following code simply takes input character wise, then check for each character if there is space more than once it skips it else it prints the character. Same logic you can use for tab also. Hope it helps in solving your problem. If there is any problem with this code please let me know.
int c, count = 0;
printf ("Please enter your sentence\n");
while ( ( c = getchar() ) != EOF ) {
if ( c != ' ' ) {
putchar ( c );
count = 0;
}
else {
count ++;
if ( count > 1 )
; /* Empty if body */
else
putchar ( c );
}
}
}