Try practicing a lot a language after learning it. That way it's less likely that you mix up concepts.
I learned C then Java at my university... then in 5 days i learned C++ by myself, I wrote for that matter an simple class then a template class, and those where enough. Now I use C, prolog, and C++ with openGL at several disciplines. Most of my other colleges don't even know what C++ is, and they only use C and badly... They are the kind of people that only cares with exames...
Look what a partner of mine once wrote...
Code:
int GetString(char *str, int len, int x, int y) {
int i=0;
char ch=0;
while(ch!=13) {
if((ch = GetCh()) != -1) {
if(ch==27)
return 0;
if(i>=len-1 && ch!=13 && ch!=8)
beep();
else {
if(ch==27)
return 0;
else{
if(ch==8) {
if(i==0)
beep();
if(i>0) {
i--;
SetCursorPosition(y, x+i);
PutChar(' ');}
} else {
SetCursorPosition(y, x+i);
PutChar(ch);
str[i]=(char)ch;
i++;}
}
}
}
updateTime();
}
str[i-1] = 0;
return 1;
}
And my improved version...
Code:
int GetString(char *str, int len, int x, int y) {
int i=0;
char ch=0;
while(1){
updateTime();
ch = GetCh();
switch(ch){
case -1: break;//key not pressed
case 27: return 0;//cancel
case 8: //backspace
if(i<=0)
beep();
else{
i--;
SetCursorPosition(y, x+i);
PutChar(' ');
}
break;
case 13://enter
str[i]=0;
return 1;
default://another char
if(i>=len-1){//size to big
beep();
break;;
}
SetCursorPosition(y, x+i);
PutChar(ch);
str[i]=(char)ch;
i++;
break;
}
}
}
Consider yourself lucky Brain Cell