20 Temmuz 2012, Cuma
Yaz .txt dosyası?
.txt
Bir dosya içine metin bir parça yazabilirim?
Üzerinden 3-4 saat Googling oldum, ama bunu yapmak için nasıl öğrenemez.
fwrite();
çok fazla argüman var, ve nasıl kullanılacağını bilmiyorum.
Sadece bir isim yazmak istiyorum ve .txt
bir dosya için birkaç sayı olduğunda kullanmak için en kolay işlevi nedir?
Edit: kod benim. bir parça Eklendi
char name;
int number;
FILE *f;
f = fopen("contacts.pcl", "a");
printf("\nNew contact name: ");
scanf("%s", &name);
printf("New contact number: ");
scanf("%i", &number);
fprintf(f, "%c\n[ %d ]\n\n", name, number);
fclose(f);
CEVAP
20 Temmuz 2012, Cuma
FILE *f = fopen("file.txt", "w");
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
/* print some text */
const char *text = "Write this to the file";
fprintf(f, "Some text: %s\n", text);
/* print integers and floats */
int i = 1;
float py = 3.1415927;
fprintf(f, "Integer: %d, float: %f\n", i, py);
/* printing single chatacters */
char c = 'A';
fprintf(f, "A character: %c\n", c);
fclose(f);
Bunu Paylaş:
hangi kural gitignore dosyası yok sayı...
Okuma bir Excel dosyası PHP...
Chrome komut dosyası hata ayıklayıcısı...
Nasıl bir toplu iş dosyası komut satır...
CSV dosyası bir yorum alabilir miyim?...