I'm trying to take text from a multiline text input and break it up to into
string Address[7] but to do this I need to know how to break the text up at \n
so if I have "Hello world\nI am mikey\nThis is line 3"
I need to break it up to fill the different indexes
So far I have this but need to join beginning and end.
Code:void _labelguiFrame::OnButton2Click(wxCommandEvent& event) { //Get address from box wxString instring = AddressTextIn->GetValue(); //Process address to insert spacings at beginning of lines //Break up string to lines string address[7]; //!!!More code here...!!! //Reform with added spaces //str length for labels is 26, so 3+22+3 string linebegin = " "; string printstring; int x = 0; int y = 7; while (x<y) { //Address output here if ( x < y - 1 ) { printstring = printstring + linebegin + address[x] + "\n"; } else { printstring = printstring + linebegin + address[x]; } cout<<linebegin<<address[x]<<endl; x++; }; //Address to the printer //Setup printer ofstream print; print.open("lpt1:", ios::out); //cout<<printstring; print<<"\x1b\x43\x09"; print<<printstring; print<<"\x1b\x0c\x1b\x07\x1b\x07"; print.close(); wxMessageBox(_("The label has printed.\nPlease peel it off and press\nreturn when label has been ejected.")); //End print job by resetting printer, and pulling back paper. print.open("lpt1:", ios::out); print<<"\x1b\x40"; print.close(); }