Cipher message

I have received cipher documents which are believed to be secret messages. So, my mission is to break the encoding and reveal what the secrets are that each file contains. However,it is believed that each file contains a message protected with a "null cipher" which surround the real characters in messages with one or more "null" characters. So, to reveal the message, I have to read in each character in the file, but only print out every other, or every third, or every fourth character.

I already built my project and it debugged successful. However, I can't decode the secret and I stuck right here. I am confusing and wondering that I have built it correctly or not. So please take a look over my project and give me your opinion. Thanks.

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;

int main(int argc, char * argv[])
{
int c, count = atoi(argv[1]);
srand(time(NULL));
c = rand();
char b;
do
{
for (int i = 1; i < count; i++)
c = getchar();
cout.put(c);


b = cin.get();
cout.put(b);
}while(!cin.eof());
}

You need an fstream: http://www.cplusplus.com/reference/iostream/fstream/ or http://www.cplusplus.com/reference/iostream/ifstream/

read it char by char (like char ch; in >> ch;) until not eof (instead of 'do ... while' better use a while loop)

check if it wasn't eof
and
check if it wasn't 0
if those condition are ok -> print it
Topic archived. No new replies allowed.