Here is some code:
class String {
private:
char s[255]; //Ow, yee, let me write a long text baby, oh, wait, only 255 :(/>
int l; // Length, good naming convention :)/>
short error;
...
}
The >> operator:
//operator >>
istream & operator>>(istream &is,String &x)
{
x.l=0; char k; //l - length
while ((k=_getche()) != 13) { //13 - enter
x.s[x.l]=k;
x.l++;
if(k == 8) {x.l-=2; cout<<char(32)<<char(8);} //8 - backspace, 32 - spacebar, Length -= 2 because backspace increments by 1 but I delete 1 instead
if(x.l<0) x.l=0;
} x.s[x.l]=0; //Length can't be lower than 0, don't go lower on delete
cout<<endl;
return is;
} //Isn't it beautiful? :)/> The interesting thing is that I used <iostream> and still did all this crappy keyPress events
Oh, looks like I deleted the code where I was converting the String into numbers, oh, that was the real nightmare, and actually that's why I deleted it... The max number it was able to converto to was 999,999,999

New Topic/Question
Reply




MultiQuote






|