[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

#include "stdafx.h" #include <iostream> #include

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 1

File: 1447107757319.jpg (49KB, 436x467px) Image search: [Google]
1447107757319.jpg
49KB, 436x467px
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class Paragraph {
public:
void setCode();
void getCode();
void decode();
private:
string code;
};

void Paragraph::setCode() {
ifstream inFS;
inFS.open("Input");
getline(inFS , code);
inFS.close();
};

void Paragraph::getCode() {
cout << code << endl << endl << endl;
};

void Paragraph::decode() {
for (int i = 0; i < code.length(); i++) {
char characterHolder = code.at(i);
char newCharacter = characterHolder - 3;
characterHolder = newCharacter;
}
ofstream onFS;
onFS.open("Output");
onFS << code;
onFS.close();
};

int main()
{
Paragraph code;
code.setCode();
code.getCode();
code.decode();
code.getCode();
return 0;
}

the above code is intended to take a string of gobbledegoop my professor provided on a .txt file (Input.txt) and translate it into a coherent phrase by subtracting 3 from the ascii value of each character. the result is then supposed to be recorded into Output.txt. what are some reasons this may not be working?
>>
>>232653

https://www.youtube.com/watch?v=pGXV1c7VcG0

bump
>>
>>232653
Too lazy to check/run it, but you say you're want to read and write to a Input.txt and Output.txt. But in you code you open Input and Output.
>>
>>232663

Just tried that but I got the same result as last time I ran it, a blank console window. Anything else I could be forgetting?
>>
>>232666
add onFS.flush(); just before onFS.close();
>>
>>232667

Same result as last time. I think it might be having trouble grabbing the string from the text file but idk why that would be.
>>
>>232670
replace
characterHolder = newCharacter;
with
code[i] = newCharacter;

It works on my end (with the previous changes aswell).
>>
>>232676

nope, no change
>>
>>232677

I tried code.at(i) as well and still nothing
>>
>>232679
PLease note that when running from visual studio it requires the Input.txt in the same folder as the root of the code and not in the debug/release folder.
>>
>>232684

do you mean with the .cpp?
>>
>>232686
Yeah, don't just drag it into the visual studio project, copy it to were the cpp files are
>>
>>232684

https://www.youtube.com/watch?v=xos2MnVxe-c

It's working now! Thanks for the help!
Thread posts: 13
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.