c++ - File read and output bug -


i using bellow struct 'menu' store menu data; after able read file use loops load of menu data each menu. variable vector of char* used store options in each menu. used freetype library display menu options on menu buttons created using opengl.

char n = 0,  tempbuffer[32]; file * menu = fopen ("menudatum.txt","r"); fgets (tempbuffer , 32 , menu); menue[n].variable.push_back(tempbuffer);//"text here");  << fclose (menu); 

string literal commented '<<' work buffer outputs weird characters based on size of tempbuffer when used (as needed): if it's size 32 4c, or if it's 16 lk, etc; if output using cout displays in file properly... have neither problem input or output do? also, 'char* tempbuffer = "text here";' display '"text here"' library through struct;etc. string literal does.

the text in file merely 'text here'

here menu struct well; not pasting of code because extensive

struct drawings::menues {     std::vector<char*> variable;     bool orrient;     float xpos, xposf, ypos, yposf, cr, cb, cg, ca, slicewidth, slicespacing;     unsigned char options; } menue[3]; 

without seeing code, it's hard tell. crystal ball(r) tells me have e.g. vector store these "strings". since pointers , use local buffer, can't store data , gets corrupted later on.

std::ifstream in("menudatum.txt"); std::string line; if(!getline(in, line))     throw std::runtime_error("failed read menudatum.txt");  std::vector<std::string> variable; variable.push_back(line); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -