help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Terminal input with scanf


From: Andreas Weber
Subject: Re: Terminal input with scanf
Date: Thu, 18 Oct 2018 17:53:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0

Am 18.10.18 um 07:19 schrieb Saji Kuttan:
I want to input multiple column data from terminal that have to be stored into separate variables. I use input and scanf functions for inputting data.

What do you really want to do? Do you want some user interaction (please insert blabla) or do you want to have a script which works like a *nix CLI program (working with args, read from stdin)

Then I use the scanf function in the C style. The code is given below.
[a,b]=scanf("%d %f", "C")
> in which I ask an integer and float data from the user. Actually, this
> works well but the scanf waits for one more input from terminal. Why
> scanf is asking one more input? How to get rid of it?

It waits for EOF. Try pressing CTRL+D after you've entered the second value.

Or see this example:

$ echo "4 5.67" | octave --eval '[a,b]=scanf("%d %f", "C")'
a =  4
b =  5.6700

HTH Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]