Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int menu();
- int file_open();
- int main(int argc, char **argv) {
- while(1) {
- int n = 0;
- char c;
- if (scanf("%d%c", &n, &c) == 2 && c == '\n') {
- if (n == 1) {
- if (file_open()==1)
- continue;
- else {
- printf("n/a\n");
- //break;
- }
- } else if (n == -1) {
- break;
- } else {
- printf("n/a");
- break;
- }
- } else {
- printf("n/a");
- break;
- }
- }
- return 0;
- }
- int menu() {
- int n = 0;
- char c;
- if (scanf("%d%c", &n, &c) == 2 && c == '\n') {
- }
- return n;
- }
- int file_open() {
- int tmp = 0;
- int i = 0;
- //char *str;
- char name[80];
- scanf("%s", name);
- //printf("%s\n", name);
- FILE *fp;
- if ((fp = fopen(name, "r")) != NULL)
- {
- tmp = 1;
- char y;
- //printf(getc(fp) == EOF? "EMPTY" : "NO EMPTY");
- int check_empty = 0;
- while (fscanf(fp, "%c", &y) != -1) {
- printf("%c", y);
- check_empty = 1;
- }
- if (check_empty == 1)
- printf("\n");
- else
- printf("n/a\n");
- fclose(fp);
- }
- return tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement