hello everyone,
how do i make this program display error message if the user inserts non-numbers or decimal number (in Matrix A).
(only whole numbers are allowed to use as input)
(This is what i'm supposed to do though i dont know what code should i write to display the error message)
void MatrixA(short nZeileA,short nSpalteA)
{
printf("Matrix A Zeilen: ");
scanf("%d",&nZeileA);
printf("\nMatrix A Spalten: ");
scanf("%d",&nSpalteA);
}
int main()
{
char chAuswahl;
short a[5][5],b[5][5],c[5][5],d[5][5];
short i=0,j=0,k=0,nSpalteA=0,nSpalteB=0,nZeileA=0,nZeileB=0;
printf("A => Matrix A eingeben\n");
printf("B => Matrix B eingeben\n");
printf("M => Berechne AB und Ausgabe\n");
printf("T => Transporniere B und Ausgabe\n");
printf("==============================\n");
printf("E => Ende\n\n");
fflush(stdin);
printf("Auswahl: ");
scanf("%s",&chAuswahl);
switch(chAuswahl)
{
case 'A':
case 'a':
{
system("CLS");
MatrixA(nZeileA,nSpalteA);
break;
}
If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.