Limit number of cout error

Hello. I was wondering how to limit error message to one only.
For example

1
2
3
4
5
6
7
 cin.getline(stringname,7);
       for(int i=0;i<size;i++){
          if(strcmp(stringname, "hello")=0)
            cout<<"Found!"<<endl;
          else
            cout<<"not found"<<endl;
}

not found
not found
.......


I want to get only once not found

The break statement would be great here.
http://msdn.microsoft.com/en-us/library/37zc9d2w.aspx

-Albatross
Create a boolean flag outside of the for loop and initialize it to zero. If at any point in the for loop you find the string you are looking for you flip it over to one otherwise you leave it alone. Then, after the for loop is done, you check the status of that flag and output accordingly.
Topic archived. No new replies allowed.