Created
October 26, 2018 07:27
-
-
Save tot0rokr/b62410dfed7d89668d162320e58637f2 to your computer and use it in GitHub Desktop.
logical operation trick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void file_open(FILE** fp) | |
{ | |
char str[1024]; | |
*fp || (((*fp = fopen("test.txt", "w"), fprintf(*fp, "hello!\n")), fclose(*fp)), *fp = fopen("test.txt", "r")); | |
fscanf(*fp, "%s", str); | |
printf("%s", str); | |
} | |
int main() | |
{ | |
FILE *in; | |
in = fopen("test.txt", "r"); | |
file_open(&in); | |
fclose(in); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment