cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
string search
string search
Apr 7, 2015 at 6:29pm UTC
Thamsanqa Chembe
(2)
How do you search a string so that if the string begins with the letter "b" then I can know whether a student will be undergrad or postgrad? So basically I need to know if the string begins with "b" or not.
Apr 7, 2015 at 6:36pm UTC
TarikNeaj
(2580)
Strings are like arrays.
string grade =
"Beaver"
;
If you want to check the first letter. Its simply grade[0]. grade[0] in this case is "b". grade[1] is "e" and so on and so forth.
1
2
3
4
if
(grade[0] ==
'b'
) {
//stuff
}
Last edited on
Apr 7, 2015 at 6:37pm UTC
Apr 7, 2015 at 7:05pm UTC
Thamsanqa Chembe
(2)
Thanks alot
Topic archived. No new replies allowed.