getchar - Can't understand return value of getche() C -
#include <stdio.h> #include <conio.h> #define max 30 void main() { char str[max]; char str2[max]; int i=0; char c2,c1; printf("inserire stringa 1:\n"); { c2=getche(); if(c2<0) { c1=getche(); } else { c1=c2; } str[i]=c1; i++; }while(i<=max&&c1!='\n'); printf("\n"); i=0; printf("inserire stringa 2:\n"); { c2=getche(); if(c2<0) { c1=getche(); } else { c1=c2; } str2[i]=c1; i++; }while(i<=max &&c1!='\n'); printf("\n");
}
i can't understand code does.expecially if cycle:when c2<0?what return getche function? while condition giving me problems:even if press enter doesn't esc fro cycle , overwrite first word until don't write 20 chars.
Comments
Post a Comment