read() doesn't add NULLs to the end of your array, so checking for NULL won't work. read() DOES return how many bytes it read, so you could just stop there instead, but --
read() doesn't stop at the end of a line, either. You should read one by one and check for newlines yourself. You could try something like this:
Ok, so I have a shell script which runs a specific command, and that command sends it's output to the display. At certain times, the command sends buffered output, and at other times, the command sends unbuffered output in the form of a % progress bar, so if I run the command, the output I receive... (0 Replies)
hello everybody.. im new to this forum.. i have sme basic knowledge about unix.. but not too much.. i would like to practice shell programs n perl using a unix simulator.. but then i don't know wht a unix simulator means? just a bald definition that it creates a unix working environment in windows... (5 Replies)
If i simulate a load on a solaris system to choke the system to 90% CPU usage .. what is likely to increase .. my systems fan rpms, cpu temperature, power drawn .. Can anybody tell me (4 Replies)
Hey,
Task seems to be quite easy, but I'm still a bit green in shell scripting. I hope you can help me a bit. I have to run some simulation at the distance by remote terminal.
Normally when I'm working on the server directly I just type:
mpirun -np 8 compressibleInterFoam -parallel > log.txt... (7 Replies)
Hi,
I'm just start to learning simulate a network protocol using C/C++ and Java from scratch.
Actually, I want to make two nodes can communicate using TCP and UDP protocol, for example http connection and video streaming, respectively.
Can anyone help me find several references or guidance... (0 Replies)
Hello, everybody, I'm thankful for the great helps you gave during the past year.
Now I'm facing a serious problem:
I was obliged to write a 2D collision simulation applet, and my experience is only in C,C++,Intelx86 assembly. I have no experience in Java and the like, and I don't know... (2 Replies)
Hi guys,
I recently discovered this problem and any help would be great.
1) Create a file in vi named Accounts_File with the following data:
The user, the name, the pin number, current balance and transaction history.
There are 3 users who need to be inputted with all their PIN, etc... (1 Reply)
# Create the simulator object that we need in order to run NS
set ns
# Set the parameters that we will use for wireless communications
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set... (0 Replies)
are there any popular DDoS simulation tools to test my own infrastructure? Anyone tried to setup all these in AWS EC2? (1 Reply)
Discussion started by: boriskong
1 Replies
LEARN ABOUT OSF1
gets
gets(3) Library Functions Manual gets(3)NAME
gets, fgets - Get a string from a stream
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <stdio.h>
char *gets(
char *string);
char *fgets(
char *string,
int n,
FILE *stream);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
gets(), fgets(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Points to a string to receive bytes. Specifies an upper bound on the number of bytes to read. Points to the FILE structure of an open
file.
DESCRIPTION
The gets() function reads bytes from the standard input stream, stdin, into the array pointed to by the string parameter. Data is read
until a newline character is read or an end-of-file condition is encountered. If reading is stopped due to a newline character, the newline
character is discarded and the string is terminated with a null byte.
The fgets() function reads bytes from the data pointed to by the stream parameter into the array pointed to by the string parameter. Data
is read until n-1 bytes have been read, until a newline character is read and transferred to string, or until an end-of-file condition is
encountered. The string is then terminated with a null byte.
NOTES
The gets() function does not check the input for a maximum size. Consequently, if more bytes are entered than will fit in the space allo-
cated for the string parameter, gets() will write beyond the end of the allocated space, producing indeterminate results. To avoid this
condition, use fgets() instead of gets().
RETURN VALUES
Upon successful completion, the gets() and fgets() functions return string. If the stream is at end-of-file, the end-of-file indicator for
the stream is set and a null pointer is returned. If a read error occurs, the error indicator for the stream is set, a null pointer is
returned, and errno is set to indicate the error.
ERRORS
The fgets() and gets() functions set errno to the specified value for the following conditions: The O_NONBLOCK flag is set for the underly-
ing stream and the process would be delayed by the read operation. The file descriptor underlying the stream is not a valid file descrip-
tor or is not open for reading. The read operation was interrupted by a signal which was caught and no data was transferred. The call is
attempting to read from the process's controlling terminal and either the process is ignoring or blocking the SIGTTIN signal or the process
group is orphaned. Insufficient memory is available for the operation. The device associated with stream does not exist.
RELATED INFORMATION
Functions: clearerr(3), feof(3), ferror(3), fgetws(3), fileno(3), fopen(3), fputws(3), fread(3), getc(3), getwc(3), puts(3), scanf(3)
Standards: standards(5) delim off
gets(3)