hi, everyone!
please take a look at my program:
it does fine on first try but after the first looping of the code it does something unnecessary and i don't know why it does that.Code:int main() { while(1) { printf("\n>> "); gets(cmd_str); split_cmd(); if( strcmp(cmd_wrds[0],"MAKE") == 0 ) make(); } return 0; } int make(void) { char matrix_name; matrix_name=cmd_wrds[1][0]; if (matrix_name == 'A') v=0; else if (matrix_name == 'B') v=1; else if (matrix_name == 'C') v=2; printf("Enter number of rows: "); scanf("%d",&row); printf("Enter number of columns: "); scanf("%d",&col); for (i=0;i<row;i++){ for (j=0;j<col;j++){ printf("%c[%d][%d] = ",matrix_name,i,j); scanf("%d",&m[v][i][j]); }} return 0; }
it's like this:
what seems to be the problem?Code:>>MAKE A Enter number of rows: 2 Enter number of columns: 2 A[0][0] = 1 A[0][1] = 2 A[1][0] = 3 A[1][1] = 4 >> //this is what i'm talking about, it should only show once before asking for another command >>MAKE B
by the way, the program still works fine after the first loop, i think, it's just that ">>" that's bothering me. where did it came from?
thanks to those who'll help!



LinkBack URL
About LinkBacks



