Guest User

Untitled

a guest
Nov 2nd, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <cstdlib>
  5. #include <ctime>
  6. using namespace std;
  7.  
  8.  
  9.  
  10.  
  11. int main ()
  12. {
  13. srand(time(NULL));
  14. char str[256];
  15. ifstream fin("Story.dat");
  16. ofstream fout("output.dat"); // open file
  17. short Rand;
  18. Rand = ((rand() % 10) + 1);
  19.  
  20. while (fin >> str) // loop while extraction from file is possible
  21. {
  22. fout << str << endl;
  23. }
  24.  
  25. fin.close();
  26. fin.open("output.dat");
  27.  
  28.  
  29.  
  30. while (fin >> str)
  31. {
  32. cout << str << ' ';
  33. }
  34. cout << endl;
  35.  
  36. while (fin >> str)
  37. {
  38. if (str == "*nounp*")
  39. {
  40. fin.open("nouns.dat");
  41. for (int i = 0;i < 4; i++)
  42. {
  43. fin >> str;
  44.  
  45.  
  46. }
  47. cout << str;
  48. fin.open("Story.dat");
  49. }
  50. else
  51. cout << str << ' ';
  52. }
  53.  
  54. return 0;
  55. }
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment