c++ hilfe

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/c-hilfe_236447/page_1 - zur Vollversion wechseln!


Moesli schrieb am 24.10.2013 um 23:34

ich bin leider in C nicht fitt,... wich kann ich den folgenden output in eine datei schreiben append ?:

Code: C
printf(" : [key %i]\n ", ev.code);


COLOSSUS schrieb am 25.10.2013 um 00:32

Das ist C, nicht C++. Bitte nicht diese zwei Sprachen ueber einen Kamm scheren.

fprintf(3) verraet dir jedenfalls, wie das geht. fopen(3) wirst du jedenfalls auch noch dazu brauchen, sowie danach (optional) fflush(3) und fclose(3).


schrieb am 25.10.2013 um 00:35

http://pastebin.com/zYSJ5gXh

http://www.cplusplus.com/reference/cstdio/fprintf/
http://www.cplusplus.com/reference/cstdio/fopen/

http://www.klausschmaranz.com/Downloads.aspx


Paxi schrieb am 25.10.2013 um 11:08

Oder in C++ (nicht getestet)
http://www.cplusplus.com/reference/fstream/ofstream/

Code: CPP
#include <fstream>

int main() {

   // open output file stream 
   std::ofstream myFile("myfile.txt");

   // use operator << to write something to the file
   myFile << " : [key " << ev.code << "]\n";

   // close file stream
   myFile.close();

   return 1;
}

Edit: Statt "\n" kann man in C++ auch std::endl schreiben, (endl = end line).


Moesli schrieb am 05.12.2013 um 12:44

thx @ all




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025