It certainly is showing error but you're not looking for it. That's what scanf()'s return value is for, it returns 0 if it reads no values, 1 if it found 1 value, 2 for 2, etc. Each %... code counts as one "value".
The buffering thing is a known issue with scanf(). It's a "feature" -- it stops scanning at the first bad character -- which is pretty useless if you're not building a compiler.
fflush should work, if you tell it which stream to flush, which you are not. But the proper way to avoid these buffer problems is to not use scanf().
You can still use sscanf though, which is just as good without the problems! It scans a string, and has no buffer to leave things in.
Here's the usual way to do it:
Last edited by Corona688; 08-08-2014 at 12:18 PM..
When I worked with client-server (socket) programming, I encountered "the socket error# 10055" which means "No buffer space available". This might be a symptom of one or more applications that didn't return system resources (like memory) properly. Temporary solution was to reboot the machine to... (7 Replies)
how can i redirect standard input? i dont remember :/, though could you redirec not from a command? i mean, to redirect always stdin and stout (1 Reply)
PROGRAM A <-> PROGRAM B
PROGRAM A sends data as STDIN ro PROGRAM B and when PROGRAM B is executed from PROGRAM A, it sends output back to PROGRAM A. This is implemented using 2 pipes (fd1 & fd2).
The above process happens in a loop and during the second run, the previous data that had been... (10 Replies)
Hello,
I am having trouble clearing the serial port buffer using the iclear and iflush commands. The code runs without errors being returned, but when I check the buffer again there is still data.
The only way I have so far is to read until there is nothing left in the buffer. Shouldn't one... (1 Reply)
I have a program R installed on Ubuntu under /usr/bin/R. I also have a different version installed under /home/user/R. I would like to invoke the locally installed program temporarily. How can I do this automatically by running a script and then switching to the default program?
thanks,
SM (2 Replies)
Hi,
How can i clear the command. Suppose using esc k i retrieved teh command, but for some reason I want to clear and type fresh one... how can i do that.
thx (2 Replies)
I'm running a ksh script that requires user interaction, and said users (myself among them) may get a little trigger happy and get ahead of ourselves and accidentally key in the wrong responses to future prompts in the script.
Naturally, I'd like to prevent that, so how does one clear that... (0 Replies)
Hello everyone,
Can someone please explain the input buffer behaviour for the read command in ksh93 on AIX?
I have 'googled' for weeks now, and did not find a satisfactory answer or solution to my dilemma.
I have the following code:
STTY=$(stty -g)
if ;then
stty -echo -icanon time 0 min... (1 Reply)
Just started learning Unix and received my first assignment recently. We haven't learned many commands and honestly, I'm stumped. I'd like to receive assistance/guidance/hints.
1. The problem statement, all variables and given/known data:
How do I write a shell script that takes in a file or... (4 Replies)
Discussion started by: fozilla
4 Replies
LEARN ABOUT OPENSOLARIS
acctmerg
acctmerg(1M) System Administration Commands acctmerg(1M)NAME
acctmerg - merge or add total accounting files
SYNOPSIS
/usr/lib/acct/acctmerg [-a] [-i] [-p] [-t] [-u] [-v]
[filename] ...
DESCRIPTION
acctmerg reads its standard input and up to nine additional files, all in the tacct format (see acct.h(3HEAD)) or an ASCII version thereof.
It merges these inputs by adding records whose keys (normally user ID and name) are identical, and expects the inputs to be sorted on those
keys.
OPTIONS -a Produce output in ASCII version of tacct.
-i Produce input in ASCII version of tacct.
-p Print input with no processing.
-t Produce a single record that totals all input.
-u Summarize by user ID, rather than by user ID and name.
-v Produce output in verbose ASCII format, with more precise notation for floating-point numbers.
EXAMPLES
Example 1 Using the acctmerg command.
The following sequence is useful for making "repairs" to any file kept in this format:
example% acctmerg -v <filename1>filename2
Edit filename2 as you want:
example% acctmerg -i <filename2>filename1
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWaccu |
+-----------------------------+-----------------------------+
SEE ALSO acctcom(1), acct(1M), acctcms(1M), acctcon(1M), acctprc(1M), acctsh(1M), fwtmp(1M), runacct(1M), acct(2), acct.h(3HEAD), utmpx(4),
attributes(5)SunOS 5.11 22 Feb 1999 acctmerg(1M)