
- Forum
- Programming Talk
- C and C++
- How to achieve this - Minimum Code to Strip Blank Spaces
How to achieve this - Minimum Code to Strip Blank Spaces
This is a discussion on How to achieve this - Minimum Code to Strip Blank Spaces within the C and C++ forums, part of the Programming Talk category; Hi All, I have a string with blank space throughout the string that is at several places in between the ...
-
How to achieve this - Minimum Code to Strip Blank Spaces
Hi All,
I have a string with blank space throughout the string that is at several places in between the string. But I want the final output of the string with the blank spaces stripped off or removed off. How to achieve the above with minimum line of code in C program?
Regards,
Norman
-
Hi,
One way to remove space would be to use isspace() function. One can check each character whether it is isspace() and if satisfies leave that can go to the next character. If it is not satisfied you can store that character in a character array separately. After the whole string is checkd theycan print the new character array which has all the spaces removed in it. But while thinking in this line I have a related question namely what is the header file under which this isspace is placed. Somebody clarify this because this also need to be included while using isspace() function. Also let me know whether isispace can handle only single-space.
Regards,
Allan
-
Hi,
The header file under which isspace() is present is ctype.h. The use of isspace() is a interesting idea for the problem. But I think there would be more ways to handle the same problem. Can someone suggest some more ways to handle the problem?
Regards,
Blenda
-
Hi,
The function isspace() can handle single space, tab, vertical tab, form feed, carriage return, or newline. The function isspace() returns non-zero if its argument has any of the space mentioned above. Otherwise isspace() returns zero.
Regards,
Norman
-
Sponsored Ads

Reply With Quote





