codescracker


c

C fputc()



« Previous Function Next Function »


fputc()

The fputc() function is used to write the character ch to the specified stream at the current file position and then advances the file position indicator.

fputc() Syntax

#include<stdio.h>
int fputc(int ch, FILE *stream);

The value returned by the fputc() function is the value of the character written. In case if an error occurs then EOF is returned.

fputc() Example

Following function writes the contents of a string to the specified stream:

void write_string(char *str, FILE *fp)
{
	while(*str)
	{
		if(!ferror(fp))
		{
			fputc(*str++, fp);
		|
	}
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test