BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Questions about use of scanf / getchar() in Borland/CppBuild

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Gordon Holtom
Guest





PostPosted: Wed Aug 02, 2006 7:21 am    Post subject: Questions about use of scanf / getchar() in Borland/CppBuild Reply with 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") 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





PostPosted: Wed Aug 02, 2006 3:57 pm    Post subject: Re: Questions about use of scanf / getchar() in Borland/CppB Reply with quote



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





PostPosted: Wed Aug 02, 2006 9:18 pm    Post subject: Re: Questions about use of scanf / getchar() in Borland/CppB Reply with quote



"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.