Re: function



Bill Cunningham wrote:

.... snip ...

comparing argument with a without a cast or something like that
the compiler said. Without cast and comparing was mentioned by
the compiler but it compiled and didn't work. So I tried this.

if((fputc(a,fp))==NULL)
puts("fputc error");

When I ran the binary fputc error was mentioned 10 times. My
2nd arg was 10.

Look up what a function does and returns before you use it. In
this case:

7.19.7.3 The fputc function

Synopsis
[#1]
#include <stdio.h>
int fputc(int c, FILE *stream);

Description

[#2] The fputc function writes the character specified by c
(converted to an unsigned char) to the output stream pointed
to by stream, at the position indicated by the associated
file position indicator for the stream (if defined), and
advances the indicator appropriately. If the file cannot
support positioning requests, or if the stream was opened
with append mode, the character is appended to the output
stream.

Returns

[#3] The fputc function returns the character written. If a
write error occurs, the error indicator for the stream is
set and fputc returns EOF.

Note the returned value.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


** Posted from http://www.teranews.com **
.



Relevant Pages

  • Re: If you got to choose the syntax, what would you do?
    ... pretty common these days, so I should put in a few thoughts. ... Do they execute the tokens serially from the stream or do they ... execute tokens from the outside world, or put a Forth compiler in there ...
    (comp.lang.forth)
  • Re: PL/I features
    ... Early commercial I/O could use stream. ... channel and dropped directly into the buffer where PL/I then read it. ... Both the compiler and compiled code had to reside ...
    (comp.lang.pl1)
  • Re: String handling in .txt file.
    ... > have been developed with some compiler specific syntax. ... I don't think you have a syntax issue, ... > text stream to a printer on LPT1. ... > characters that cause the routine to abort. ...
    (alt.comp.lang.learn.c-cpp)
  • Interacting with a long-lived external process from ruby?
    ... I have a long-lived process that I am trying to get ruby to interact ... compiler and allows for exponentially faster, ... Is there some way to 'reopen' an IO stream that has been closed ... It seems like reopening the write ...
    (comp.lang.ruby)
  • Re: is cin always the keyboards input?
    ... > that suggests to me that you are using a very old compiler. ... I need to flush, yes. ... My intention is to create an application for showing of debug stream ...
    (comp.lang.cpp)