Exforsys

Free Training

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 ...

Go Back   Exforsys > Programming Talk > C and C++

Exforsys.com


C and C++ C and C++

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 06-17-2006, 06:30 PM
Member
 
Join Date: May 2006
Posts: 45
norman is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-17-2006, 07:51 PM
Member
 
Join Date: May 2006
Posts: 45
Allan is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-17-2006, 08:05 PM
Member
 
Join Date: May 2006
Posts: 47
blenda is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-17-2006, 08:20 PM
Member
 
Join Date: May 2006
Posts: 45
norman is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:30 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.