text cross contue

well my last post was not descirptive enough at all so this is my new one. all the code of this might be to long but i am tring to create a function that will retunr the value of the number of chars i enter. in visual basic they have all the string operating functions all set for you but i need to make one that will work for c++. i came up with this so far:

countchar()
{
for(n=0;n<?;n++)
{
?
return n;
}
}
there will be cin in main that will take the charr sequence and call to this function. my question is how do i find the last character for the n<? and if needed what do i put in the brakets besides return n; i thought i could make a pointer equal to the charcter sequence and find the greatest memory block in it but i dont know how to do that either. if this post is not clear enough pls tell me so thank you.
can i see ur full code...?
Aren't you just looking for strlen() ? As for how it works,
1
2
3
4
5
int my_strlen( const char * str ) {
   int n = 0;
   while( str[n] != 0 ) n++;
   return n;
}

The important thing to know is that strings end with a null character.
thanks hamsterman i think that works
Topic archived. No new replies allowed.