1#include <assert.h>2#include <stdlib.h>3#include <stdio.h>4#include <string.h>56/*7output:8testing9done10end:11*/1213int14main(void)15{16 char buff[40], *s;17 FILE *fp;1819 puts("testing");20 fp = fopen("__NOT_A_FILE", "w");21 assert(fp);22 fputs("Hello\n", fp);23 fflush(fp);24 assert(ferror(fp) == 0);25 fclose(fp);26 assert(rename("__NOT_A_FILE", "__NOT_OTHER_FILE") == 0);2728 fp = fopen("__NOT_OTHER_FILE", "r");29 assert(fp);30 s = fgets(buff, sizeof(buff), fp);31 assert(s != NULL);32 assert(strcmp(s, "Hello\n") == 0);33 fclose(fp);3435 assert(remove("__NOT_OTHER_FILE") == 0);36 puts("done");3738 return 0;39}