I want to make a function that will do the same as Strlen does, andI get the error: "string subscript out of range". I tried fixing it but has no idea.
heres the code:
#include "stdafx.h"
#include "stdafx.h"
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int strlen1( string str)
{
    int count=0;
    int i=0;
    while (str[i]!='\0')
        {
            count++;
            i++;
    }
    return count;
}
int _tmain(int argc, _TCHAR* argv[])
{
    string input;
    cin >> input;
    cout << strlen1(input) << endl;
    return 0;
}
thanks!
 
     
     
     
    