Ok but now for every error, its saying same size as yes, but not yes.... instead of me entering KK and it saying same size as no, but not no
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int X;
X=1;
while(X=1)
{
char option[3];
cout<<"Are you going to want to loop?\nYes or No: ";
cin>>option;
if(sizeof(option)<2)
{
cout<<"Now why are you trying to enter something too tiny (pun intended) ;-)";
}
if(sizeof(option)>3)
{
cout<<"This isn't the time for buffer overflows yet";
}
if(sizeof(option)==3&&!(strcmp(option,"yes")==0||strcmp(option,"Yes")==0))
{
cout<<"Tisk tisk, you tried to fool me by entering something the same size as yes, but not yes.\n";
}
if(sizeof(option)==2&&!(strcmp(option,"No")==0||strcmp(option,"no")==0))
{
cout<<"Tisk tisk, you tried to fool me by entering something the same size as no, but not no.\n";
}
else
{
if(strcmp(option,"Yes")==0||strcmp(option,"yes")==0)
{
char buffer[10];
cout<<"Ok, now try to overflow me\n";
cin>>buffer;
cout<<buffer;
cin.ignore();
cin.get();
}
if(strcmp(option,"No")==0||strcmp(option,"no")==0)
{
char buffer[10];
cout<<"Ok, now try to overflow me\n";
cin>>buffer;
cout<<buffer;
cin.ignore();
cin.get();
X=0;
}
}
}
return 0;
}
and if i type no it says the yes error but brings me to the overflow point
eDIT: Ahhh, should change to two first ||'s to &&'s
Brb