Sponsored Content
Full Discussion: erroneous output
Top Forums Programming erroneous output Post 302126322 by bishweshwar on Wednesday 11th of July 2007 06:37:35 AM
Old 07-11-2007
erroneous output

#include<stdio.h>
int main ()
{
FILE* f_read;
FILE* f_write;
char *string[80];
f_read=fopen("file1","r");

while(!feof(f_read));
{
fscanf(f_read,"%s",string);
fprintf(stdout,"%s\n",string);
}

return 0;
}


INPUT FILE
___________
manu
jilu
ruta

OUTPUT
-----------
manu
jilu
ruta
ruta

why the last line is being read two times
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting a File with an Erroneous Period

Hi - I am new to the Unix environment and have encountered a problem I can't resolve. I inadvertently created a data file with a period/dot at the end of the word 'dat', I.e. filename.dat. and can't remove it using the 'rm' command. In attempting to do so, I receive a message reading that the... (3 Replies)
Discussion started by: PLF
3 Replies

2. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies

3. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

6. Shell Programming and Scripting

Erroneous file concatenation.

I have more than one files in a directory , namely GLOW_OUT.txt FIELD_OUT.txt BASE_OUT.txt ... SHOW_OUT.txt What I wanted to do is to I am working in Korn Shell What I did was : for file in <directory_name>/*.* ;do cat $file | grep -v '^$' >> temp_file rm $file done ... (7 Replies)
Discussion started by: kumarjt
7 Replies
STDIO(3S)																 STDIO(3S)

NAME
stdio - standard buffered input/output package SYNOPSIS
#include <stdio.h> FILE *stdin; FILE *stdout; FILE *stderr; DESCRIPTION
The functions described in section 3S constitute a user-level buffering scheme. The in-line macros getc and putc(3S) handle characters quickly. The higher level routines gets, fgets, scanf, fscanf, fread, puts, fputs, printf, fprintf, fwrite all use getc and putc; they can be freely intermixed. A file with associated buffering is called a stream, and is declared to be a pointer to a defined type FILE. Fopen(3S) creates certain descriptive data for a stream and returns a pointer to designate the stream in all further transactions. There are three normally open streams with constant pointers declared in the include file and associated with the standard open files: stdin standard input file stdout standard output file stderr standard error file A constant `pointer' NULL(0) designates no stream at all. An integer constant EOF (-1) is returned upon end of file or error by integer functions that deal with streams. Any routine that uses the standard input/output package must include the header file <stdio.h> of pertinent macro definitions. The func- tions and constants mentioned in sections labeled 3S are declared in the include file and need no further declaration. The constants, and the following `functions' are implemented as macros; redeclaration of these names is perilous: getc, getchar, putc, putchar, feof, ferror, fileno. SEE ALSO
open(2), close(2), read(2), write(2), fread(3S), fseek(3S), f*(3S) DIAGNOSTICS
The value EOF is returned uniformly to indicate that a FILE pointer has not been initialized with fopen, input (output) has been attempted on an output (input) stream, or a FILE pointer designates corrupt or otherwise unintelligible FILE data. For purposes of efficiency, this implementation of the standard library has been changed to line buffer output to a terminal by default and attempts to do this transparently by flushing the output whenever a read(2) from the standard input is necessary. This is almost always transparent, but may cause confusion or malfunctioning of programs which use standard i/o routines but use read(2) themselves to read from the standard input. In cases where a large amount of computation is done after printing part of a line on an output terminal, it is necessary to fflush(3S) the standard output before going off and computing so that the output will appear. BUGS
The standard buffered functions do not interact well with certain other library and system functions, especially vfork and abort. LIST OF FUNCTIONS
Name Appears on Page Description clearerr ferror.3s stream status inquiries fclose fclose.3s close or flush a stream fdopen fopen.3s open a stream feof ferror.3s stream status inquiries ferror ferror.3s stream status inquiries fflush fclose.3s close or flush a stream fgetc getc.3s get character or word from stream fgets gets.3s get a string from a stream fileno ferror.3s stream status inquiries fopen fopen.3s open a stream fprintf printf.3s formatted output conversion fputc putc.3s put character or word on a stream fputs puts.3s put a string on a stream fread fread.3s buffered binary input/output freopen fopen.3s open a stream fscanf scanf.3s formatted input conversion fseek fseek.3s reposition a stream ftell fseek.3s reposition a stream fwrite fread.3s buffered binary input/output getc getc.3s get character or word from stream getchar getc.3s get character or word from stream gets gets.3s get a string from a stream getw getc.3s get character or word from stream printf printf.3s formatted output conversion putc putc.3s put character or word on a stream putchar putc.3s put character or word on a stream puts puts.3s put a string on a stream putw putc.3s put character or word on a stream rewind fseek.3s reposition a stream scanf scanf.3s formatted input conversion setbuf setbuf.3s assign buffering to a stream setbuffer setbuf.3s assign buffering to a stream setlinebuf setbuf.3s assign buffering to a stream sprintf printf.3s formatted output conversion sscanf scanf.3s formatted input conversion ungetc ungetc.3s push character back into input stream 4th Berkeley Distribution May 13, 1986 STDIO(3S)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy