Desc :

 

int fprintf( FILE *stream, const char *format[, argument ]...);

printf 처럼 형식 지정자 사용하여 문자열을 쓸 수 있다.


Source Code :

#include <stdio.h>

void main()
{
	FILE *fp;
	int i = 12345;

	fp = fopen("C:\\Users\\w4135\\OneDrive\\141test.txt", "w+"); 

	if (fp == NULL)
	{
		puts("파일을 생성할 수 없습니다.");
	}
	else
	{
		fprintf(fp, "%d", i); //fp에 12345저장
	}
}

 


Result :

+ Recent posts