How can one code a function to remove all trailing blanks from the right end of a string, assuming i use

void trimRight(char a[]);

Recommended Answers

From the end of the string walk backward until you find a non-blank character, then overwrite the last blank you saw with '\0'. Easy peasy, and here's a working example of an rtrim …

Jump to Post

All 2 Replies

From the end of the string walk backward until you find a non-blank character, then overwrite the last blank you saw with '\0'. Easy peasy, and here's a working example of an rtrim function to get you rolling.

ok

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.