Hello,
I would like removing all leading and trailing blank characters from a string. I know it is possible in C++ using trim. But is it also possible in C. I am using a borland Compiler
Thx
Ewout Schiferli
Hello,
I would like removing all leading and trailing blank characters from a string. I know it is possible in C++ using trim. But is it also possible in C. I am using a borland Compiler
Thx
Ewout Schiferli
Will you post an example string so I can see what you mean please?
Why don't you just write your own function. It would be easy - just pass the function a string, read through it character by character, and write any non-blanks into another string. Then simply return the new string...
It should take about five lines of code (probably best if you write them yourself though)
Here's an example of the string:
Hello world!
How are you.
Ok.
These three lines I would like to save as a string like:
Hello world! How are you. Ok.
Ok, so post your code attempt and we'll help you along the way. Doubtless someone will ruin your learning experience by just posting the whole freeking answer, but in the long run, you'd be better off if we can help you understand / learn the process by showing us your attempt and any errors you're getting.
It's fairly basic:
1) while this letter is a space, skip ahead one letter.
2) while this letter is not a space, copy this letter someplace
3) copy one space to someplace
4) without actually using the word 'goto', go to step 1 until you run out of letters.
5) Since we're out of letters, 'someplace' should now hold our end results. Do something with it.
Quzah.
Hope is the first step on the road to disappointment.
Thank you
I will start immediately
You can use the isspace function.