By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

how to TRIM BEGINNING and END BLANK spaces in STRING???

P: 14
hi!
i need help in C programming to TRIM BEGINNING and END BLANK spaces in STRING.....
Feb 18 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,510
hi!
i need help in C programming to TRIM BEGINNING and END BLANK spaces in STRING.....
have a look at tutorials on string manipulation in C, e.g.
http://www.cprogramming.com/tutorial/lesson9.html
Feb 18 '07 #2

P: 14
nothing there on removing BEGINNING and END BLANK spaces....

are there any function to use?
Feb 18 '07 #3

Expert 100+
P: 1,510
nothing there on removing BEGINNING and END BLANK spaces....

are there any function to use?
If you can work in C++ you could use function find_first_not_of() in class <string>
http://www.cppreference.com/cppstring/index.html

otherwise if you are working in C is to search the character array for the first non space character then copy the characters from that point into another array. When that is working you can then reverse search the resultant sting replacing the first of the trailing spaces with a '\0'
Feb 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.