Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>//remove
  3. #include <conio.h>
  4. #include <sstream> //sstream includes all the ostringstream stuff. it also has <string> in it, so you don't need to include that anymore
  5. using namespace std;
  6.  
  7.  
  8. 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
  9. {
  10.  
  11. string sub;
  12. // static int scrnlen = 80;
  13. int lastspc = 0;
  14. while(dumpstr.size() > scrnlen)
  15. {
  16. int temp = 0;
  17. while(temp < scrnlen)
  18. {
  19. lastspc = temp;
  20. temp = dumpstr.find(' ', temp + 1);
  21. }
  22. sub = dumpstr.substr(0, lastspc);
  23. dumpstr = dumpstr.substr(lastspc + 1, dumpstr.length() - 1);
  24. cout << sub << endl;
  25. }
  26. cout << dumpstr << endl;
  27.  
  28. }
  29.  
  30.  
  31. void main()
  32. {
  33. /////////////////////////
  34.  
  35. string open = "Your character";
  36. 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";
  37.  
  38. int bob = 5; //just to show you stuff
  39. ostringstream oss; //create one like so
  40. oss << open << desc << " " << bob;//add stuff to it like so.
  41.  
  42. print(oss.str());//the .str() function of an ostringstream returns a string object
  43.  
  44. int size;
  45. int iterator;
  46.  
  47. size = (desc.size()+open.size());
  48.  
  49. char* printout = NULL;
  50.  
  51. printout = new char[size];
  52.  
  53.  
  54. while(/*not at end of open)*/)
  55. /////////////////
  56.  
  57. for (iterator=0; iterator<size; iterator++)
  58. {
  59. printout[iterator];//=each char in the array of desc
  60. }
  61. while(/*not at end of desc*/)
  62. for (iterator; iterator<size; iterator++)
  63. {
  64. printout[iterator];//=each char in the array of desc
  65. }
  66.  
  67. delete [] printout;
  68. printout = NULL;
  69.  
  70.  
  71. print(printout);
  72.  
  73. cout << "Your character ";
  74. print(desc,size);
  75. cout << "\nHis name is Guillermo.";
  76.  
  77. getch();
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement