現在、すべてのデータを保存する場所として .txt ドキュメントを使用して、C でデータベースを作成しようとしています。しかし、fputs() で行をシフトすることができないため、プログラムがこの .txt ドキュメントに書き込むことはすべて 1 行だけです。
int main(void){
char c[1000];
FILE *fptr;
if ((fptr=fopen("data.txt","r"))==NULL){
printf("Did not find file, creating new\n");
fptr = fopen("data.txt", "wb");
fputs("//This text file contain information regarding the program 'monies.c'.\n",fptr);
fputs("//This text file contain information regarding the program 'monies.c'.\n",fptr);
fputs("//Feel free to edit the file as you please.",fptr);
fputs("'\n'",fptr);
fputs("(Y) // Y/N - Yes or No, if you want to use this as a database",fptr);
fputs("sum = 2000 //how much money there is, feel free to edit this number as you please.",fptr);
fclose(fptr);
}
fscanf(fptr,"%[^\n]",c);
printf("Data from file:\n%s",c);
fclose(fptr);
return 0;
}
これは私のテスト ドキュメントです。私はすべてを試してからいくつかを試したように感じますが、行を変更することはできません。助けていただければ幸いです。ところで。出力は次のようになります。