 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gordon Holtom Guest
|
Posted: Wed Aug 02, 2006 7:21 am Post subject: Questions about use of scanf / getchar() in Borland/CppBuild |
|
|
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.
--------------------------------------------------------------------------------
Help Feedback Home Pages Newsgroups Search
Made in Borland® Copyright© 1994-2002 Borland Software Corporation. All rights reserved. Legal Notices, Privacy Policy |
|
| Back to top |
|
 |
Bruce Larrabee Guest
|
Posted: Wed Aug 02, 2006 3:57 pm Post subject: Re: Questions about use of scanf / getchar() in Borland/CppB |
|
|
Just out of curiosity why don't you want to allow the use of the carriage
return after the user input?
Anyway try getch() instead. Please note though that getch() doesn't echo
the character to the screen, you'll have to take care off that...
Bruce |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Aug 02, 2006 9:18 pm Post subject: Re: Questions about use of scanf / getchar() in Borland/CppB |
|
|
"Gordon Holtom" <grdnholtom (AT) aol (DOT) com> wrote in message
news:44d00c3f$1 (AT) newsgroups (DOT) borland.com...
| Quote: | 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")
|
This is not an IDE issue. This group is for discussions regarding the use
of the IDE itself. You should direct your question to the language.cpp
newsgroup instead.
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|