You are here:

C/getting rid of unnecessary spaces in a string

Advertisement


Question
I'm doing a c project and am facing a problem gettin rid of spaces, someone asked u this Q before, but i didnt fully get ur answer, imagine i have a string
"  I li ke   chicken" and i want my output to be
"I like chicken"
u said to check the first string and copy any character thats not a space into another array however wouldnt that give u something like "Ilikechicken" thnx for ur help

Answer
You cannot make your program intelligent.
You can either remove all the spaces or tell your program to remove a particular character sitting at a particular place.
But, you cannot make it understand the ENGLISH word and remove space only in specific cases (such as your example).

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.