0

hi!

i have a problem..
i want to make a program the will input your name and age, and the output will count the char i been input. but my problem is i don't know what would be the code so that i can count the char i been input..
can someone help me? i dont need the whole program.. i just need the code.. thanks guys.. ^_^

4
Contributors
4
Replies
7
Views
9 Years
Discussion Span
Last Post by FrancisC07
0
int main()
{
    char input[256];
    cout << "Insert name: ";
    cin.getline(input,256);
    cout << "\nYou name is " << (int)strlen(input) << " characters long.\n";
    cin.ignore();
    return 0;
}
0

we prefer to use strings with getline but there we go, it's a much more reliable solution since you don't have to worry about size

string test;
getline(cin, test);
cout << test.length();

Chris

0

now i got it!! ^_^ thank you very much for helping me guys! it gives me a great info. thanks ^_^

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.