Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. Mac Shell: Downloads/>$ rm numbers.txt
  2. # Downloaded new numbers.txt file from windows.
  3. Mac Shell: Downloads/>$ ./Project1
  4.  
  5. Raw output:
  6. -----------
  7. Segmentation fault: 11
  8. Mac Shell: Downloads/>$
  9.  
  10. void do_file_magic(string file){
  11. string line, replace = "", numeral, dump = "", temp;
  12. ifstream source ("numbers.txt");
  13. if (!source.is_open()) {
  14. die_a_clean_death("Unable to open source file:", file);
  15. };
  16.  
  17. // Display output to console:
  18. sep("Raw output:");
  19.  
  20. // read source file and output vowels to destination file.
  21. while ( getline(source, line) || true) {
  22. dump = dump + replace;
  23. if ( line[0] != ' ') {
  24. temp = num2string(roman2num(line));
  25. line = remove_whitespace(line);
  26. replace = line + string(17-line.size(), ' ') + temp + "n";
  27.  
  28. // If you read this then you noticed that there was some shenagins going on.
  29. } else {
  30. numeral = num2roman(string2num(line));
  31. line = remove_whitespace(line);
  32. replace = numeral + string(17 - numeral.size(), ' ') + line + "n";
  33. };
  34. if(source.eof()) {
  35. break;
  36. }
  37. };
  38. printf("file dump: n%s", dump.c_str());
  39.  
  40.  
  41. // Close the files
  42. source.close();
  43.  
  44. // open the file in output mode nuking everything from orbit.
  45. // (Its the only way to be sure)
  46. ofstream destination("numbers.txt");
  47. if (!destination.is_open()) {
  48. die_a_clean_death("Unable to open destination file:", file);
  49. };
  50.  
  51. // Just dump a variable to the file.
  52. destination << dump << "n";
  53.  
  54. destination.close();
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement