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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.