Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Searching character by character

Searching character by character

Searching character by character

How do I search through arrays character by charcter looking for spaces in order to count the words ?

I have gone as far as saving the info from two seperate windows in two different arrays, on selecting a menu option 'Save' as can be seen from the code below:


case IDM_SAVE:

GetWindowText(hWndSmall, Module[index].szTitle, TITLESIZE);
GetWindowText(hWndBig, Module[index].szAbstract, ABSTRACTSIZE);


Hope 1 of you can shine a light on this.
Thanks! Really Appreciated!

RE: Searching character by character

I don't really know whether you are using strings or character arrays.  Anyway, if it is a string, you can always get the c_str() to do the same thing.

int spaces = 0;
char* str = ...; // your string with words and spaces
while (str != 0 && *str != '\0')
    str = strchr (str, ' ');
    if (str != 0)
       // move to character after the space
int words = spaces + 1;

This assumes you do not have multiple spaces between words.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close