Welcome to E8 :: [eon8]

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll also be able to use the shoutbox, customize your profile, change themes, gain reputation points for submitting content, while also communicating with other members via your own private messenger, plus much more!


This message will be removed once you have signed in.

Sign in to follow this  

I need help with my program.

4 posts in this topic

I need to read in a file and use an 'Nth' null terminator to decrypt a message, so basically taking every nth term and placing it in a new file, or printing it to the screen.

The problem is, when I compile it runs fine and asks me what nth term to null, but than skips all my nested loops and goes straight to "You put in the wrong file" and never decrypts anything.

#include <iostream>
#include <fstream>
#include "string"
using namespace std;
int main()
int x = 1; //using 1 is used for first char of document
int y = 1;
int z; //the three integers are counters
string inputfile;
char letter;
cout << "Insert name of document" << endl;
cin >> inputfile;
cout << "What is the good nth number?" << endl;
cin >> z;
z = z-1; //will get rid of every nth number - 1
ifstream infile(inputfile.c_str()); //opens user defined file
if (infile.is_open()) //ensuring file is open
{//main loop begins
while (!infile.eof())
if ((x-y) == z)
cout << letter;
y = x;
}//killed while loop
}//ended if loop
else //only used if user input the wrong file name
cout << "You put the wrong file in...Therefore causing an error. try again use: filename.txt" << endl;
cout << "you used this:" << inputfile << endl;

Share this post

Link to post
Share on other sites

Nevermind, I figured it out...

If anyone knows how to create a file with a user defined name, and write to it, lemme know please.

Share this post

Link to post
Share on other sites

nevermind. I figured it out. Now I have an encrypt/decrypt program. Simple, yet elegant. And fail safe. What happened to all the people in this site?! where have they all gone?!

Share this post

Link to post
Share on other sites

Eh, I monitor things... Tend to fade in and out.

Shit, anyone who liked RenegadeRecon on here? If so, their excellent site has been taken down. What a shame. It was THE place to get airsoft information. I'm not into airsoft anymore, but I checked to see if anything new was there.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this