3 /* fputs( const char *, FILE * )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 int fputs( const char * _PDCLIB_restrict s, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
15 /* FIXME: This is devoid of any error checking (file writeable? r/w
18 /* FIXME: Proper buffering handling. */
19 while ( stream->bufidx < stream->bufsize )
21 if ( ( stream->buffer[stream->bufidx++] = *(s++) ) == '\0' )
29 return fputs( s, stream );
40 #include <_PDCLIB_test.h>
48 char text[] = "SUCCESS testing fputs().";
49 TESTCASE( ( fh = fopen( "testfile", "w" ) ) != NULL );
50 TESTCASE( fputs( text, fh ) != EOF );
51 TESTCASE( fclose( fh ) == 0 );
52 TESTCASE( ( fh = fopen( "testfile", "r" ) ) != NULL );
53 TESTCASE( fread( buffer, 1, strlen( text ), fh ) == strlen( text ) );
54 TESTCASE( memcmp( buffer, text, strlen( text ) ) == 0 );
55 TESTCASE( fclose( fh ) == 0 );
56 TESTCASE( remove( "testfile" ) == 0 );