Skip to main content
gamedev.net
🔒 Locked

Searching Strings

Started by MrPoopypants Feb 18, 2003 at 5:59 PM 1 replies 200+ views
Original Post
MrPoopypants
MrPoopypants
(C++) How can I search a String and eliminate the commas, apostrophies, periods, and spaces to have just the text remain using pointers. This is what I think might work (my program is nowhere near ready to be compiled)
  
if ( *Ptr == ''''''/*amd would this even work*/ || *Ptr == '','' || *Ptr == ''.'' || *Ptr == '' '' )
{
//what would go here?

Ptr++;
}
  
Any help would be greatly appreciated. Thanks in advance
(0110101101000110)The Murphy Philosophy: Smile . . . tomorrow will be worse.
civguy
civguy
You need two pointers. One that reads, one that writes. They initially point to same location, but when you encounter a character you want to eliminate, the reading pointer will move forwards but the writing pointer will stay still. Normally the both would move forward. Don''t forget ''\0'' at the end of the string.
MrPoopypants
MrPoopypants
Thanks a lot
(0110101101000110)The Murphy Philosophy: Smile . . . tomorrow will be worse.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.