Compare string and skip trailing blanks 
Author Message
 Compare string and skip trailing blanks

Look up strtok(). I think you should be able to build what
you need fairly easily by using that. Maybe you need to
copy the original string to a working buffer, then hit that
with strtok a few times.
--
Dan Evens
(Standard disclaimers etc. No spam please.)



Quote:
> Hello, I am quite new to C++ and I am trying to write a function that
does
> the following:
> The function is called CompareItems(...)
> it is a member function of a class it takes an array of characters and
> compares it to an internal Array of chars....
> it must skip leading and trailing blanks,and compares the arrays
character
> by character, converting characters to upper case...
> My problem is that the string.h functions strcmp family take into account
> trailing and leading blanks, but my functions must not take into account
> trailing, leading blanks and tabs...
> Could someone give me an example how I could do that?

> I would really appreciate any piece of code explaining how to compare to
> array of chars, ignoring blanks and tabs...
> please e-mail me at:

> thank you.



Sun, 13 May 2001 03:00:00 GMT  
 Compare string and skip trailing blanks
Hello, I am quite new to C++ and I am trying to write a function that does
the following:
The function is called CompareItems(...)
it is a member function of a class it takes an array of characters and
compares it to an internal Array of chars....
it must skip leading and trailing blanks,and compares the arrays character
by character, converting characters to upper case...
My problem is that the string.h functions strcmp family take into account
trailing and leading blanks, but my functions must not take into account
trailing, leading blanks and tabs...
Could someone give me an example how I could do that?

I would really appreciate any piece of code explaining how to compare to
array of chars, ignoring blanks and tabs...
please e-mail me at:

thank you.



Sun, 13 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Search string where sub_string has trailing blanks

2. Leading and Trailing Blanks

3. Leading and Trailing Blanks

4. skipping blank lines in files

5. Skip blank lines in file

6. need to compare to structs, field by field, audit trails

7. Compare 2 files not taking blanks into account

8. Comparing empty strings and null strings

9. finding the closest match of a string compared to an array of strings

10. Comparing strings and reading strings

11. removing trailing spaces from a string

12. Skipping string input with fscanf ?

 

 
Powered by phpBB® Forum Software