Xcode Problem beim schreiben in Datei (c++)

J

jak8

Mitglied
Thread Starter
Dabei seit
19.09.2006
Beiträge
37
Reaktionspunkte
0
Guten abend,

ich schreibe gerade eine kleine Übung zu c++ mit Xcode. In einer nebenfunktion sollen die Eingaben, die man macht gespeichert werden.
Hierzu folgender Code:

int se(car ca[32]){
char buff[1000], buff1[32], buff2[32], * hpc;
int i=0, hp;
FILE * fp;
fp = fopen("speichern.txt","w+");
while (ca.exist() != 0) {
ca.getStuff(buff1, buff2);
hp = ca.getHp();
sprintf(hpc,"%d", hp);
strcat(buff, buff1);
strcat(buff, "\t");
strcat(buff, buff2);
strcat(buff, "\t");
strcat(buff, hpc);
strcat(buff, "\n");
i++;
};
fwrite(buff, 1, sizeof(buff), fp);
fclose(fp);
return 0;
}\\

Sind ein paar workarounds drin, aber das essentielle ist, dass der string "buff" in die datei "speichern.txt" geschrieben werden soll.
Wenn ich compile und renne (...).
Also wenn ich Build and run mache startet das programm normal. Ich mache meine eingaben, usw. Wenn ich jetzt die speichern und beenden funktion aufrufe kommt folgender Text:\\

[Session started at 2009-11-07 21:54:18 +0100.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 306.
Xcode could not locate source file: cpu_capabilities.h (line: 246)

Das Problem ist definitiv in der speichern funktion, weil es vorher nicht da war.
Die speichern.txt wird zwar erstellt, bleibt aber leer.

Hatte jemand schonmal so ein problem?
Was mache ich falsch?
 
Zurück
Oben Unten