Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mac Shell: Downloads/>$ rm numbers.txt
- # Downloaded new numbers.txt file from windows.
- Mac Shell: Downloads/>$ ./Project1
- Raw output:
- -----------
- Segmentation fault: 11
- Mac Shell: Downloads/>$
- void do_file_magic(string file){
- string line, replace = "", numeral, dump = "", temp;
- ifstream source ("numbers.txt");
- if (!source.is_open()) {
- die_a_clean_death("Unable to open source file:", file);
- };
- // Display output to console:
- sep("Raw output:");
- // read source file and output vowels to destination file.
- while ( getline(source, line) || true) {
- dump = dump + replace;
- if ( line[0] != ' ') {
- temp = num2string(roman2num(line));
- line = remove_whitespace(line);
- replace = line + string(17-line.size(), ' ') + temp + "n";
- // If you read this then you noticed that there was some shenagins going on.
- } else {
- numeral = num2roman(string2num(line));
- line = remove_whitespace(line);
- replace = numeral + string(17 - numeral.size(), ' ') + line + "n";
- };
- if(source.eof()) {
- break;
- }
- };
- printf("file dump: n%s", dump.c_str());
- // Close the files
- source.close();
- // open the file in output mode nuking everything from orbit.
- // (Its the only way to be sure)
- ofstream destination("numbers.txt");
- if (!destination.is_open()) {
- die_a_clean_death("Unable to open destination file:", file);
- };
- // Just dump a variable to the file.
- destination << dump << "n";
- destination.close();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement