ועוד אתה שואל אותי איך C ניראת?
-35 אחרי המרה מקוד ASCCI היא 13 = מקש ENTER .. וכבר פתרתי את זה בדרך הזאת:
#include <stdio.h> #include <conio.h> void main() { int l; for (l=1;l<=20;l++){ int ch,ch1,ch2,ch3,code; while ((ch != -35) || (ch2 != -35)||(ch1 != -35)||(ch3 != -35)) { ch=getch(); while (ch==13) { printf("\nyou must enter a number.\n"); ch=getch(); } printf("*"); ch=(ch-48); ch1=getch(); if (ch1==13) { code=1; break; } else { printf("*"); ch1=(ch1-48); } ch2=getch(); if (ch2==13) { code=2; break; } else { printf("*"); ch2=(ch2-48); } ch3=getch(); if (ch3==13) { code=3; break; } else { printf("\nyou cant enter more then 3 digits, please enter again:\n"); } }//end main while if (code==1) code=ch; if (code==2) code=(ch*10)+ch1; if (code==3) code=(ch*100)+(ch1*10)+ch2; printf("\n%d\n",code); } }
עכשיו אני ישתמש ב switch אולי יהיה קצר יותר.. תודה בכל מקרה.