Hey everyone! I want to do a basic thing but for some strange reason there is something not working.
I need to write to a file but I'm handling all the code in a callback function, which in turn is declared in a class. Here is the architecture of my code:
But this doesn't work, the file gets created but it allways overwrites itself which is not what I need to do.Code:int main (int argc, char **argv) { ImageConverter Aclass; while(1); //infinite loop return 0; } class ImageConverter { //some variables .. public: ImageConverter (): { } ~ImageConverter () { } void imageCb () //this function gets called when I receive an image frm server { .... //some calculations fstream outfile ("directory/train.txt"); outfile.open ("directory/train.txt", fstream::in | fstream::out | fstream::app); outfile<<"P,"<<SomeValues<<endl; outfile.close(); .... } };
Can anyone please tell me what I am doing wrong? Is it because i am constantly declaring outfile?
Thanks