string search

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.

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
Thanks alot
Topic archived. No new replies allowed.