{
    char op;
    cout << "enter test ";
    cin >> op;
    if(op == 'test')
          cout << "test sucessful\n";
    else
          cout << "w00t\n";
          
    system("pause");
}

Right now i can type toggle and the program will display test succesful because toggle starts with t i need it so like if i type tset it will say w00t. I need it to check the whole word and not just the first letter. How do i go about doing this?

Recommended Answers

All 2 Replies

Use a string instead:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string op;

    cout << "enter test ";
    cin >> op;

    if(op == "test")
        cout << "test sucessful\n";
    else
        cout << "w00t\n";
}

sweet thanks a lot man! its people like you that make this forum great for newcomers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.