Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>//remove
- #include <conio.h>
- #include <sstream> //sstream includes all the ostringstream stuff. it also has <string> in it, so you don't need to include that anymore
- using namespace std;
- void print(char dumpstr[],int scrnlen; )//why did you change dumpstr into a char []. you have to do all your own math that way. you can't use .size or .find or .substr or any of that stuff. keep it a string variable
- {
- string sub;
- // static int scrnlen = 80;
- int lastspc = 0;
- while(dumpstr.size() > scrnlen)
- {
- int temp = 0;
- while(temp < scrnlen)
- {
- lastspc = temp;
- temp = dumpstr.find(' ', temp + 1);
- }
- sub = dumpstr.substr(0, lastspc);
- dumpstr = dumpstr.substr(lastspc + 1, dumpstr.length() - 1);
- cout << sub << endl;
- }
- cout << dumpstr << endl;
- }
- void main()
- {
- /////////////////////////
- string open = "Your character";
- string desc = "likes to bake ceramic hands while skipping across a moonlit beach wearing boots made from the skin of an albino llama. His eyes are sewn on saucepans, bubbling with effervescent causality and endless ephemerality";
- int bob = 5; //just to show you stuff
- ostringstream oss; //create one like so
- oss << open << desc << " " << bob;//add stuff to it like so.
- print(oss.str());//the .str() function of an ostringstream returns a string object
- int size;
- int iterator;
- size = (desc.size()+open.size());
- char* printout = NULL;
- printout = new char[size];
- while(/*not at end of open)*/)
- /////////////////
- for (iterator=0; iterator<size; iterator++)
- {
- printout[iterator];//=each char in the array of desc
- }
- while(/*not at end of desc*/)
- for (iterator; iterator<size; iterator++)
- {
- printout[iterator];//=each char in the array of desc
- }
- delete [] printout;
- printout = NULL;
- print(printout);
- cout << "Your character ";
- print(desc,size);
- cout << "\nHis name is Guillermo.";
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement