Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
#include <stdio.h> #include <iostream.h> FILE* pfile; char* text = 0; char* t1 = 0; class txt { private: public: erstellen(void) { if(( pfile = fopen("blabla.txt","w+")) == 0) { printf("es funzt nicht"); return 1; } else { printf("es wurde eine txt-Datei erstellt\n"); } } void schreiben(char* text) { fprintf(pfile, text); } void lesen(void) { fscanf(pfile,"%d", &t1); cout<<t1; } }; void main(void) { txt textdatei; textdatei.erstellen(); textdatei.schreiben("aheee"); textdatei.lesen(); } |
Zitat
char* t1 = 0;
...
fscanf(pfile,"%d", &t1);
Anonymous
unregistriert
Anonymous
unregistriert
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 |
fscanf(FILE* datei, const char* format, arg1, arg2, argx); FILE* datei; int arg1, arg2; datei = fopen("...", "r"); z.b. fscanf(datei, "%d %d", &arg1, &arg2); |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
d = signed int* (dezimal) i = signed int* (dezimal) o = signed int* (oktal) u = unsigned int* (dezimal) x = signed int* (hexa) hd = signed short int* (dezimal) hi = signed short int* (dezimal) ho = signed short int* (oktal) hu = unsigned short int (oktal, bzw. dezimal) hx = signed short int* (hexa) ld = signed long int* (dezimal) li = signed long int* (dezimal) lo = signed long int* (oktal) lu = unsigned long int* (dezimal) lx = signed long int* (hexa) f, e, g = float* le, lf, lg = double* Le, LF, Lg = long double* c = char* (ohne '\0') s = char* String (mit '\0') p = void* n = int* hn = short int* ln = long int* %[nichts] = Zeichen % |
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include <stdio.h> #include <iostream.h> FILE* pfile; char* text; char* t1; class txt { public: erstellen(void) { if(( pfile = fopen("blabla.txt","w+")) == 0) { printf("es funzt nicht"); return 1; } else { printf("es wurde eine txt-Datei erstellt\n"); } } void schreiben(char* text) { fprintf(pfile, text); fclose(pfile); } void lesen(void) { pfile = fopen("blabla.txt","r"); fscanf(pfile,"%c", &t1); cout<<t1<<endl; } }; void main(void) { txt textdatei; textdatei.erstellen(); textdatei.schreiben("a"); textdatei.lesen(); } |
Quellcode |
|
1 |
t1=(char*)malloc(sizeof(char)); |
Quellcode |
|
1 |
fscanf(pfile,"%s", &t1); |
Quellcode |
|
1 |
t1=(char*)malloc(sizeof(char)*AnzZeichen); |
Werbeanzeige