| | |
c program to remove blank spaces
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Solved Threads: 7
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.
•
•
•
•
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.
"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.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
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.
ssharish
C Syntax (Toggle Plain Text)
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
•
•
•
•
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 Syntax (Toggle Plain Text)
text = text.replace(' ', '')
drink her pretty
So does Perl! In fact, you can do it with just one line, on the command line.
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.
C Syntax (Toggle Plain Text)
perl -pe 's/\s/g'
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.
C Syntax (Toggle Plain Text)
for each character in the string if the character isn't a space print it
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
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
![]() |
Similar Threads
- Error loading cmicnfg.cpl -- SOLUTION HERE! (Windows NT / 2000 / XP)
- remove extra blank spaces in a text file (C++)
- Help with lexical analyzer program (C++)
- Remove extra whitespace (C++)
- I come in Peace (Community Introductions)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Contrast calculation
- Next Thread: Problem using atoi for my argv argument
| Thread Tools | Search this Thread |
adobe ansi api array arrays asterisks binarysearch calculate centimeter char convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest kernel km linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming stack standard string strings structures systemcall testautomation turboc unix user variable voidmain() wab win32api windows.h






