This is sort of a continuation of this topic http://www.cplusplus.com/forum/beginner/11887/
Does .length() return a value that acounts for the first element being labeled 0? For example, if your string was called 'hi' and it stored the value "Hello World" would hi.length() return 10 or 11?
EDIT: "Hello World", the line break concealed the space that was there.
Check out this:
----------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
int strlength(char hi[]); //Function to find length of string
main()
{
char hi[]="Hello World";
cout<<"Length of string is:\n"<<strlength(hi); //Call to function "strlength"
getch();
}
int strlength(char hi[])
{
int length=0;
for(int i=0;hi[i]!='\0';i++) //loop until encounter null charcter
//Note:length not incremented for "/0"
length++;