954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

c program to remove blank spaces

plz provide the c program to remove the blank spaces

sivakrishna
Newbie Poster
2 posts since Jun 2008
Reputation Points: 6
Solved Threads: 0
 
plz provide the c program to remove the blank spaces


No.

That's not what we do. The way it works is *you* post your code, and also post up a description of your problem or error with that code.

We will take a look at it and suggest ways of fixing it.

We don't *do* your homework, we help you with *your* code problems.

Adak
Nearly a Posting Virtuoso
1,479 posts since Jun 2008
Reputation Points: 425
Solved Threads: 185
 

No.

That's not what we do. The way it works is *you* post your code, and also post up a description of your problem or error with that code.

We will take a look at it and suggest ways of fixing it.

We don't *do* your homework, we help you with *your* code problems.

Exactly. Also see the article 'How to ask questions the smart way' over here.

Jishnu
Posting Pro
518 posts since Oct 2006
Reputation Points: 193
Solved Threads: 25
 

LOL

but seriously, if there ever was a problem that should be solved by Perl... this is it.

look into Perl. this is the kind of problem it's designed to do. and can do it in about 3 lines of code.

jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
 

Well, ok i decided to give you hint but not the answer, here you go with some sample pesudo code. This should give you an idea on how to approch this problem.

character [] source = " We dont do your homework "
charater [] destination;

Fetch each char from the source array 
      Check if the fetched char is white space char
            if so continue the loop
      if not space char
         copy that char into destination 

print the destination ( with no white space in it )


ssharish

ssharish2005
Posting Whiz in Training
253 posts since Dec 2006
Reputation Points: 73
Solved Threads: 20
 

If this is not enough! then only God can help you.

oops!! not even God.

Luckychap
Posting Pro in Training
444 posts since Aug 2006
Reputation Points: 83
Solved Threads: 61
 

It's very easy, you know yet the algoritmus how to make it,
now you should only implementation it!

Good luck ;-)

Nashy
Newbie Poster
5 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

LOL

but seriously, if there ever was a problem that should be solved by Perl... this is it.

look into Perl. this is the kind of problem it's designed to do. and can do it in about 3 lines of code.

Python does it with one line:

text = text.replace(' ', '')
Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
 

So does Perl! In fact, you can do it with just one line, on the command line.

perl -pe 's/\s/g'

But that's beside the point.

Note that ssharish's code works, but it might be more efficient to shift the data inside the array. Or even just print characters that aren't spaces.

for each character in the string
    if the character isn't a space
        print it
dwks
Posting Whiz in Training
269 posts since Nov 2005
Reputation Points: 185
Solved Threads: 28
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You