File: 003_test_fopen.c

package info (click to toggle)
cowdancer 0.73
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 752 kB
  • ctags: 269
  • sloc: ansic: 3,822; sh: 481; makefile: 191; cpp: 6
file content (22 lines) | stat: -rwxr-xr-x 365 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*BINFMTC:
fopen test */
#include <stdio.h>
#include <stdlib.h>

void writeandclose(FILE* a)
{
  fprintf(a,"abc\n");
  fclose(a);
}

int main(int argc, char** argv)
{
  /* test that the three args work. */
  if(argc < 4)
    exit(1);
  
  writeandclose(fopen(argv[1], "r"));
  writeandclose(fopen(argv[2], "w"));
  writeandclose(fopen(argv[3], "a"));
  return 0;
}