Board index » cppbuilder » Questions about use of scanf / getchar() instructions in Borland C++
Gordon
![]() CBuilder Developer |
Questions about use of scanf / getchar() instructions in Borland C++2006-08-02 09:16:20 AM cppbuilder96 I need to be able to display an "R", followed by inputing a decimal numberv within a logical program loop without entering a caraige return ("\n") I would like the loop to repeat itself by entering a whitespace character (newline, tab or space), but exit the loop when I hit the enter key, then start again. The following shows the routine as I now have it: printf("\n\nEnter resistance number\n"); for (i= 0; i < n1; i++) { printf("\nRow %d, : \n", i+1); for (j= 0; j < maxsize04; j++) { rws1 = 30; printf("R"); scanf("%u,%c",&rws1,&s1); while ((rws1 < 0) || (rws1>maxsize20) || (cra[rws1][1] != 999)) { if (cra[rws1][1] < maxsize20) { printf("\n%1d", cra[rws1][1]); printf("\nToo Many Circuits for R Entry - Reenter "); } else if ((rws1 < 1) || (rws1>= maxsize20)) { printf("\nR Out of Range - Reenter "); printf("R"); scanf("%u,%c",&rws1,&s1); } } if (rws1 == 0) break; cr[i][j] =rws1; //R to circuit array if (rws1>rmax) rmax = rws1; if (cra[rws1][0]>maxsize20) cra[rws1][0] = i; //First circuit for this resistance else if (cra[rws1][1]>maxsize20) cra[rws1][1] = i; //Second circuit for this resistance if ((s1 != 10) && (s1 != 13)) continue; else break; } // {j} } // {i} I've tried using following the scanf instruction with a getchar() but that doesn't work either. Keying in a whitespace other than a newline (tab or space) doesn't advance the loop to print out an "R" followed by a scanf. "C" manuals have led me to believe that this would work, but it doesn't. |