c program to remove blank spaces

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 2
Reputation: sivakrishna is an unknown quantity at this point 
Solved Threads: 0
sivakrishna sivakrishna is offline Offline
Newbie Poster

c program to remove blank spaces

 
-2
  #1
Jun 23rd, 2008
plz provide the c program to remove the blank spaces
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 79
Reputation: Adak is an unknown quantity at this point 
Solved Threads: 7
Adak Adak is offline Offline
Junior Poster in Training

Re: c program to remove blank spaces

 
0
  #2
Jun 23rd, 2008
Originally Posted by sivakrishna View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: c program to remove blank spaces

 
0
  #3
Jun 24th, 2008
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.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,669
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: c program to remove blank spaces

 
0
  #4
Jun 24th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 251
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: c program to remove blank spaces

 
1
  #5
Jun 24th, 2008
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.

  1. character [] source = " We dont do your homework "
  2. charater [] destination;
  3.  
  4. Fetch each char from the source array
  5. Check if the fetched char is white space char
  6. if so continue the loop
  7. if not space char
  8. copy that char into destination
  9.  
  10. print the destination ( with no white space in it )

ssharish
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: c program to remove blank spaces

 
0
  #6
Jun 25th, 2008
If this is not enough! then only God can help you.

oops!! not even God.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 5
Reputation: Nashy is an unknown quantity at this point 
Solved Threads: 0
Nashy Nashy is offline Offline
Newbie Poster

Re: c program to remove blank spaces

 
0
  #7
Jun 27th, 2008
It's very easy, you know yet the algoritmus how to make it,
now you should only implementation it!

Good luck ;-)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: c program to remove blank spaces

 
0
  #8
Jul 2nd, 2008
Originally Posted by jephthah View Post
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:
  1. text = text.replace(' ', '')
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: c program to remove blank spaces

 
0
  #9
Jul 2nd, 2008
So does Perl! In fact, you can do it with just one line, on the command line.
  1. 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.
  1. for each character in the string
  2. if the character isn't a space
  3. print it
  4.  
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 3657 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC