brintos

brintos / llvm-project-archived public Read only

0
0
Text · 454 B · f895cf1 Raw
20 lines · cpp
1// RUN: %clangxx -g %s -o %t && %run %t2 3#include <assert.h>4#include <stdio.h>5 6int main(int argc, char **argv) {7  FILE *fp = fopen(argv[0], "r");8  assert(fp);9 10  // the file should be at least one character long, always11  assert(fgetc(fp) != EOF);12  // POSIX guarantees being able to ungetc() at least one character13  assert(ungetc('X', fp) != EOF);14  // check whether ungetc() worked15  assert(getc(fp) == 'X');16 17  assert(!fclose(fp));18  return 0;19}20