blob: 103d5e2383a99f42e05c5d56f192df1669da1db4 [file] [log] [blame]
/* Write to a file and then attempt to read
using a buffer that is not long enough. */
#include <stdio.h>
#include <string.h>
#define BUFSZ 1024
int main()
{
char buf[2*BUFSZ];
char read_buf[BUFSZ];
FILE *f;
f = tmpfile();
memset(buf, 'A', 2*BUFSZ);
fwrite(buf, sizeof(char), 2*BUFSZ, f);
fseek(f, 0L, SEEK_SET);
fread(read_buf, sizeof(char), BUFSZ*2, f);
fclose(f);
return 0;
}