Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18983

avoid newline scanf

From Rafael Oliveira <sorrizo_16@yahoo.com.br>
Newsgroups comp.lang.c
Subject avoid newline scanf
Date 2012-03-23 20:54 -0700
Organization http://groups.google.com
Message-ID <9472650.1688.1332561289799.JavaMail.geo-discussion-forums@ynlt17> (permalink)

Show all headers | View raw


Hi, I'm trying to use scanf like this:

scanf("%d%c%d", &a, &op, &b);
if (op=='+')
 c=a+b;
printf("=%d",c);

My input is 2+2, and it prints "=4". Its fine.

The problem is that I dont want a newline after scanf.

There is a way of avoid this newline?

There is a way of using "=" instead of the default end scanf char "enter"?

ty.

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

avoid newline scanf Rafael Oliveira <sorrizo_16@yahoo.com.br> - 2012-03-23 20:54 -0700
  Re: avoid newline scanf Gene <gene.ressler@gmail.com> - 2012-03-23 21:23 -0700
  Re: avoid newline scanf Kaz Kylheku <kaz@kylheku.com> - 2012-03-24 05:39 +0000
  Re: avoid newline scanf Don Y <this@isnotme.com> - 2012-03-24 00:38 -0700
  Re: avoid newline scanf Barry Schwarz <schwarzb@dqel.com> - 2012-03-24 10:20 -0700
    Re: avoid newline scanf Rafael Oliveira <sorrizo_16@yahoo.com.br> - 2012-03-24 11:57 -0700
    Re: avoid newline scanf Don Y <this@isnotme.com> - 2012-03-24 13:21 -0700

csiph-web