I'm writing a program that does a huge database import, and after profiling my code, I've found that my program spends over .25 of it's exec time trailing whitespace from each field it imports. I need a (clever) and fast way to remove trailing spaces, and insert a null where the first trailing space begins.
If I don't remove them, it takes even longer to run. All of the strings are of type:
char str[256];
Right now, I'm starting at str[255] and walking back until I hit a char other than a space (isspace() == false) and putting the '\0' on position ahead of that. Most fields are less than 20 char's long, so this is very time consuming.
Any suggestions...
Thanks
MWB.
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
If I don't remove them, it takes even longer to run. All of the strings are of type:
char str[256];
Right now, I'm starting at str[255] and walking back until I hit a char other than a space (isspace() == false) and putting the '\0' on position ahead of that. Most fields are less than 20 char's long, so this is very time consuming.
Any suggestions...
Thanks
MWB.
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.