![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Posts: 68
Rep Power: 4
![]() |
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) |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: here
Posts: 137
Rep Power: 0
![]() |
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] |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
__________________
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|