|
-
March 6th, 2006, 03:01 PM
#1
help me understand strings?
im starting to get confused. i would appriciate it if someone could help me with my noobish understandings...
1. when do i use string::size_type vs using the iterator for string?
for example, i would like to examine each character in a string. therefore i would do something like
int index = 0;
while ( index < mystring.size)
{
cout << mystring.at(stringindex);
}
now i could also print out each character in a string via the iterator?
for(myiterator = st1.begin(); myiterator != st1.end(); myiterator ++)
{
if( *myiterator == 'h')
{
do something
}
}
///////
i guess when to find out the size or length or get what is in a particular space in a string, use the size_t....when using a string function, use the iterator???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|