C & LINUX
C / LINUX printf(3) fprintf(3)
Ocean_
2022. 5. 2. 13:55
함수 기능
주어진 형식에 맞추어진 문자열을 파일에 출력하는 함수
함수 원형
#include <stdio.h>
int printf(const char *format, ...);
int fprintf(FILE *fp, const char *format, ...);
함수 파라메터
format
형식 지정자
함수 예제
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
char *text = "My test txt!\n";
FILE *fp;
fp = fopen("ssu_test.txt", "w");
printf("%s", text);
fprintf(fp, "%s", text);
exit(0);
}
리눅스시스템 프로그래밍 - 홍지만 저
교재 내에 있는 예제를 바탕으로 작성한 글 입니다.