To get rid of the carriage return in just one line, you can use
scanf ( "%d%*c", &some_variable)
The %d will get the integer and assign in some_variable.
The %*c is a %c (to get the carriage return) with a * that tell to
ignore this thing, so you dont have to assign it to a variable.
You can use * with any other format, for example, %*d, to ignore an integer.
Best regards
Carlos
On Mon, Nov 17, 2008 at 11:12 PM, boogiebehometh
<[EMAIL PROTECTED]> wrote:
> Thanx Thomas,
> Sorry, I should have done.
> I've changed the line to scanf("%c",&char_in); & it works fine now -
> Thank you!
>
> Paul C
>
> --- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>>
>> boogiebehometh wrote:
>> > Hi guys,
>> > Sorry if this is obvious to you, I'm still noob & very baffled...
>> >
>> > Basically, I scan in a number & print it to screen - large
> numbers
>> > become slightly smaller & small numbers become 10.
>> >
>> > 200 becomes 10
>> > 2000 becomes 1802
>> > 20000 becomes 19978
>> > 200000 becomes 199946
>> >
>> > I'm using the Dev C++ Compiler Version 4.9.9.2
>> > unsigned long is shown here, but i get the same results with int
> &
>> > long...
>> >
>> > Here's the code:
>> >
>> > #include <stdio.h>
>> > #include <string.h>
>> >
>> > int l;
>> > int main ()
>> > {
>> > int l;
>> > unsigned long trTime=0, trTime2=0, step=0;
>> >
>> > printf("\nEnter Transition Time(%cs): ",230);
>> > scanf("%d",&trTime);
>> > scanf("%c");
>>
>> Probably because you didn't read the documentation on how to use
>> scanf(). Every '%something' must have a parameter or you get
> undefined
>> behavior.
>>
>> > printf("\nTransition time = %d%cs\n", trTime, 230);
>> > getchar();
>> > return 0;
>> > }
>> >
>> >
>> > Anyone can explain why?
>> >
>> >
>> > cheers,
>> > Paul C
>>
>>
>> --
>> Thomas Hruska
>> CubicleSoft President
>> Ph: 517-803-4197
>>
>> *NEW* MyTaskFocus 1.1
>> Get on task. Stay on task.
>>
>> http://www.CubicleSoft.com/MyTaskFocus/
>>
>
>
--
=============================================
Carlos José de Almeida Pereira
Ilhéus - Bahia - Brasil
BLOG:
http://starfightercarlao.blogspot.com
http://starfightercarlaoenglish.blogspot.com (english version)
"Que o caminho seja brando aos teus pés;
Que o vento sopre leve em teus ombros;
Que o Sol brilhe cálido em tuas faces;
Que as chuvas caiam serenas em teus campos.
E, até que eu de novo te veja,
que a Deusa te guarde na palma da mão! "
(Bênção Irlandesa adaptada)