/***************************************************************/ /* Prof. Dr. Carsten Vogt */ /* FH Koeln, Fak. 07 / Nachrichtentechnik */ /* http://www.nt.fh-koeln.de/vogt */ /* */ /* Loesung der Uebungsaufgabe Kapitel 7, Nr. 3 */ /* aus "C fuer Java-Programmierer", Hanser-Verlag */ /***************************************************************/ #include int main(void) { FILE *fp_bin, *fp_txt; char *s = "Die natuerlichen Zahlen bis 2000000: "; long i; fp_bin = fopen("datei.bin","w+b"); fwrite(s,strlen(s),1,fp_bin); for (i=0;i<=2000000L;i++) fwrite(&i,sizeof(long),1,fp_bin); fclose(fp_bin); fp_txt = fopen("datei.txt","w+"); fprintf(fp_txt,"%s",s); for (i=0;i<=2000000L;i++) fprintf(fp_txt,"%ld ",i); fclose(fp_txt); return 0; }