{{keywords>wiki library source code example reference}}
===== putc =====
int putc(int char, FILE *stream);
put char into a stream.
===== C Sourcecode Example =====
/*
* putc example code
* http://code-reference.com/c/stdio.h/putc
*/
#include /* including standard library */
//#include /* uncomment this for Windows */
int main( void )
{
int c;
FILE *stream, *destination;
stream = fopen("test.txt", "r");
destination = fopen("test_copy.txt","w");
if (stream == 0 || destination == 0) {
perror("cannot open stream");
return 1;
}
c = getc(stream);
while (c != EOF)
{
putc(c, stdout);
putc(c, destination);
c = getc(stream);
}
fclose(stream);
fclose(destination);
return 0;
}
=== content of test.txt ===
Test example file for code-reference.com putc source code
==== output ====
./putc
Test example file for code-reference.com putc source code
output of test_copy.txt
Test example file for code-reference.com putc source code
**see also**
[[c:stdio.h:getc|]]