2つのchar []と1つのintを持つ構造体を作成しました。私はこの構造体の配列を作成し、配列にデータを格納するためにいくつかの入力を受けました。次に、このデータをファイルに書き込むためにfprintf
を使用しました。しかし、私がファイルを開くと、私はすべての新しいレコードの前にû
を得ます。 Idkなぜそれが起こっている。どこから来たものは珍しい文字がある ûdalla03332228458dallaÈfsÇûÿÿÿÿàrancho03312041265dallabanchoファイルに書き込むときの異常な文字
:ここ
FILE *outputFile=fopen("1021.txt","ab");
int tickets=0,i=1;
struct air s[30];
printf("\nEnter Number of tickets:");
scanf("%d",&tickets);
for (i=1;i<=tickets;i++)
{
printf("\nEnter the name\t");
scanf("%s",&s[i].name);
printf("\nEnter the phone number\t");
scanf("%s",&s[i].phoneNo);
printf("\n Enter the address\t");
scanf("%s",&s[i].address);
printf("Your ticket is confirmed\t");
getch();
}
for (i=0;i<=tickets;i++)
{
printf("%s", s[i].name);
printf("%s", s[i].phoneNo);
printf("%s", s[i].address);
fprintf(outputFile,"%s",s[i].name);
fprintf(outputFile,"%s",s[i].phoneNo);
fprintf(outputFile,"%s",s[i].address);
}
私は、ファイルに何を得るです:
ここでは、関連するコードですか?
[MCVE](http://stackoverflow.com/help/mcve)必須、 'struct air'とは何ですか? –
バイナリファイルとテキストファイルの入出力を混在させるのはなぜですか? –
C配列の索引付けは「0」に基づいています。 "for(i = 0; i