목적 : 입력은 지정된 디렉토리에있는 파일에 저장됩니다
단계 :
입력 경로 ①
② 텍스트 입력
결과는 다음과 같습니다 :
다음과 같이 코드입니다 :
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iostream>
#include<cstdio>
using namespace std;
#pragma warning(disable:4996)
int main()
{
char s[70];
char path[100];
printf("Input a path:\n");
scanf("%s",path);
getchar();
FILE* fp;
//cin >> paths;
if ((fp = fopen(path, "w")) == NULL) {
printf("Open the file failure...\n");
exit(0);
}
while (1) {
printf("Input a string...\ns=");
if (gets_s(s), strlen(s) < 70)
break;
printf("Too long, redo: ");
}
fputs(s, fp);
fclose(fp);
printf("\n");
return 0;
}