Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 30th, 2005, 4:21 PM   #1
Lesliect6
Programmer
 
Join Date: Aug 2005
Posts: 68
Rep Power: 4 Lesliect6 is on a distinguished road
Recognize letters

How do you make a program recognize a letter or a combination of letters (e.g. asdaasdf) in a string which I input in the program (or from a file)?
(C++ or Basic)
Lesliect6 is offline   Reply With Quote
Old Sep 30th, 2005, 5:20 PM   #2
L7Sqr
Hobbyist Programmer
 
Join Date: Jun 2005
Location: here
Posts: 137
Rep Power: 0 L7Sqr is an unknown quantity at this point
If you want to check that the string contains ONLY letters, you could use isalpha (#include <cctype>) and a loop.
To search for a particular string, the std::string has plenty of search routines, depends on how you want to go about it.
A quick google search gave me this.

Does that answer your question?
__________________
"...and though our kids are blessed their parents let them shoulder all the blame."
- The Quiet Things That No One Ever Knows [BrandNew]
L7Sqr is offline   Reply With Quote
Old Sep 30th, 2005, 5:57 PM   #3
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
http://cplusplus.com/ref/cstring/strcmp.html
__________________

tempest is offline   Reply With Quote
Old Sep 30th, 2005, 6:17 PM   #4
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
i would guess that he hasn't included error-checking in his idea. also from the question, "2" is a valid string input. yes, refer to the standard library for string manipulation functions. i get the idea that he wants to search for a particular word in an app.

there are numerous ways to do this.

good luck!
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 30th, 2005, 6:20 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Let me toss out some asides, here. Any "letter" is just a binary pattern. If you know it to be some particular coding scheme, then you can write in view of that scheme. Good implementations will attempt to adjust somewhat to the locale. The type of functions that L7 is referring to (isalpha, isnumeric, etc.) will give you more chance of success in terms of portability than mere comparison to a code table. When it comes to comparing one code against another, directly, then locale doesn't really matter except insofar as it might determine the size of a "letter". The things available to you will vary, depending upon language. You mention C++/Basic, but that's rather presumptuous. You should probably narrow it down and put it in the appropriate forum.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 30th, 2005, 7:09 PM   #6
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
what he meant is to pick your language as they each have separate libraries for this. you kind of selected an interval that's pretty broad. btw, all the pseudocode he gave you differs on language. just pick c++.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC