08-21-2012
Because that's what the %s conversion of scanf does. You should look into using fgets()
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi to all
small question for someone extremely new to the subject. Could anyone point me in the direction of the source code for a client server, message passing program?
Thanx for all your help (6 Replies)
Discussion started by: Mrchat
6 Replies
2. IP Networking
Hello there!
Can anybody help me out with the steps required in implementing a chat program using sockets?
Bye! (2 Replies)
Discussion started by: hufs375
2 Replies
3. UNIX for Dummies Questions & Answers
i need chat program in c. know sockets to some extent. (4 Replies)
Discussion started by: krishnavel
4 Replies
4. Programming
Good day everyone,
I'm doing a chat client-server program:server is to receive messages from clients through a TCP port and multicast them back to all clients through a UDP port.
This is my client program. I'd not know why it just sends and receives msg from server once, then it stops.
Is... (1 Reply)
Discussion started by: powermind
1 Replies
5. Programming
any suggestions on how i could create a simple chat program between two terminals using pipes? thanks (1 Reply)
Discussion started by: kelogs1347
1 Replies
6. UNIX for Dummies Questions & Answers
I am wanting to know if you have ever found an extremely secure
chat program for UNIX (Solaris 7), such that I could control which
users can chat with which users, ie John (teacher)
can talk to Suzy (student) or Sam (student) and they
can talk back to their teacher BUT there is absolutely ... (1 Reply)
Discussion started by: ixeye
1 Replies
7. Solaris
Hi everyone,
Normally it always easier in Sparc machine, i can set or manually use the boot-device in NVram to boot the mirrored disk. However I have a big trouble about x86 mirror for a long time. I have been doing anything i can: search document, google, ask the others.
Recently i did as... (5 Replies)
Discussion started by: tien86
5 Replies
8. Hardware
I want to build a network, in this network there is only one PC and 50 terminals, 50 students can use this system to study UNIX/Linux.
In the old days, computer was very expensive, many scientists shared a computer with terminals, that means a terminal has no cpu, memory and hardisk.
In... (5 Replies)
Discussion started by: haixiao_liu
5 Replies
9. Web Development
Hi,
I am trying to embed Skype or any other video chat/chat program into a webpage. Has anyone had success doing this? or know how?
Thanks
Phil (2 Replies)
Discussion started by: phil_heath
2 Replies
10. Shell Programming and Scripting
I need a shell script to copy files frm a linux machine to a windows machine using SCP. The files keeps changing day-to-day. I have to copy the latest file to the windows machine frm the linux machine.
for example :In Linux, On July 20, the file name will be 20.txt and it should be copied to... (3 Replies)
Discussion started by: nithin6034
3 Replies
FGETS(3P) POSIX Programmer's Manual FGETS(3P)
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond-
ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
NAME
fgets - get a string from a stream
SYNOPSIS
#include <stdio.h>
char *fgets(char *restrict s, int n, FILE *restrict stream);
DESCRIPTION
The fgets() function shall read bytes from stream into the array pointed to by s, until n-1 bytes are read, or a <newline> is read and
transferred to s, or an end-of-file condition is encountered. The string is then terminated with a null byte.
The fgets() function may mark the st_atime field of the file associated with stream for update. The st_atime field shall be marked for
update by the first successful execution of fgetc(), fgets(), fgetwc(), fgetws(), fread(), fscanf(), getc(), getchar(), gets(), or scanf()
using stream that returns data not supplied by a prior call to ungetc() or ungetwc().
RETURN VALUE
Upon successful completion, fgets() shall return s. If the stream is at end-of-file, the end-of-file indicator for the stream shall be set
and fgets() shall return a null pointer. If a read error occurs, the error indicator for the stream shall be set, fgets() shall return a
null pointer, and shall set errno to indicate the error.
ERRORS
Refer to fgetc().
The following sections are informative.
EXAMPLES
Reading Input
The following example uses fgets() to read each line of input. {LINE_MAX}, which defines the maximum size of the input line, is defined in
the <limits.h> header.
#include <stdio.h>
...
char line[LINE_MAX];
...
while (fgets(line, LINE_MAX, fp) != NULL) {
...
}
...
APPLICATION USAGE
None.
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
fopen(), fread(), gets(), the Base Definitions volume of IEEE Std 1003.1-2001, <stdio.h>
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 FGETS(3P)