One_Blog

C - ์‹œ์Šคํ…œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์˜ˆ์ œ - 1 [์‹œ์Šคํ…œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ] ๋ณธ๋ฌธ

์•Œ๊ณ ๋ฆฌ์ฆ˜

C - ์‹œ์Šคํ…œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์˜ˆ์ œ - 1 [์‹œ์Šคํ…œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ]

0xOne 2023. 3. 17. 11:52
728x90
#include<stdio.h>

int main()
{
	writeFile();
	readFile();
}

void writeFile()
{
	FILE *fp;
	fp = fopen("testFile","w");
	fprintf(fp, "File Write Test!\n");
	char testStr[1024] = "Test String.\n";
	fwrite(testStr, 100, 1, fp);
	fclose(fp);
}

void readFile()
{
	FILE *fp;
	char str[1024];
	fp = fopen("testFile","r");
	fgets(str,1024,fp); printf("%s",str);
	fread(str,1024,1,fp); printf("%s\n",str);
	fclose(fp);
}

๐Ÿ˜€