Can anyone of you tell me whether any function is available in C language to remove the white spaces at the beginning and end of a string.
-Rangan
Can anyone of you tell me whether any function is available in C language to remove the white spaces at the beginning and end of a string.
-Rangan
It would be very simple to write one - probably faster to write it than to search for an API containing such a function.
well r there no API's present.. i am have a sentence and i want to just take the blank space at the beginning and end. will strtrim() work?
WTF is strtrim()?
All you have to do is loop through the string from the beginning, eliminating spaces until you reach a non-space character. Then loop through the string from the end doing the same thing.
If you understand what you're doing, you're not learning anything.
Well thanks.,..can u explain
#define main Main /* Now try to link this! */
#define stdout stderr /* No problems, until you pipe it */
#define while(x) if(x)
#define struct union /* Great space saver */
Please use proper English and complete sentences. I understand that communicating is difficult if English is not your first language, but most other languages do have a requirement that you use complete words, sentences, and meaningful punctuation. strtrim() is not a standard function. If you are referring to a thrid-party library, please state what library that is.
It is a list of preprocessor directives that can be used as pranks. By placing this in someone else's source code it will cause bugs to appear in their program logic and mask the true source of the bug. Click on the link below that list for a better explanation.Code:Well thanks.,..can u explain #define main Main /* Now try to link this! */ #define stdout stderr /* No problems, until you pipe it */ #define while(x) if(x) #define struct union /* Great space saver */
hey buddy thanks for the reply. I just wanted to know if there is any standard function available in C language which will remove the blank spaces from the starting and ending of a sentence.
>> I just wanted to know if...
To clarify: no there aren't, at least not any standard ones that we can guarantee you'll have. Write your own, it'll be a useful excerise for you anyway.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
check 'isspace()' in ctype.h , you might find it usefull along with the other similar functions (isdigit() , isalpha()...etc)
My Tutorials :
- Bad programming practices in : C
- C\C++ Tips
(constrcutive criticism is very welcome)
- Brain Cell
r_213, you made me sorry, this thread is becoming a bit old so here's a little boost.
Now you complete the rest.Code:char *remove_white_spaces(char *dest, const char* src){ int idx_begin, idx_end; idx_begin = 0; while(src[idx_begin].....){ .... } idx_end = ...;//initialize with the index of the last char of src while(src[idx_end].....){ .... } //copy src from idx_begin to idx_end to dest return dest; }
Last edited by xErath; 11-19-2004 at 09:56 PM.