...and try only printing every fourth letter, you see:
Meet Me In Saint Louis
this is my code.However it doesn't work well
<
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
int main (int argc, char *argv[], char **env)
{
int a, count =4 ;
a = + count ;
char d;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
usingnamespace std;
int main(int argc, char *argv[])
{
int a, c, count = atoi(argv[2]);
srand(time(NULL));
c = rand() % 94 ;
c += 32 ;
a = + count;
char b;
char d;
if(argv[1] == 'e') // encryption
{
do
{for (int i = 1; i <= count; i++)
cout.put( c = (32 + rand() % 94) ) ;
b = cin.get();
cout.put(b);
} while (!cin.eof());
}
elseif (argv[1] == 'd') // decryption
{
{for(int i = 1; cin>> d; i++)
if(( i % count) == 0)
{
cout.put(a=+count);
d=cin.get();
cout.put(d);
}
return 0 ;
} while (!cin.eof());
return 0;
}
else (argv[1] != 'e' | 'd')
{
cout << " program can not work! "<< endl ;
}
return 0;
}
this is my finally code for decryption and encryption of Null Cypher. Howerver, I think I wrong somewhere. Could you please help me fix it. I want the Command Line will be
a.out e 3 - for encryption.
a.out d 3 for decryption.
Because I can compile it in in putty. it said: "ISO c++ forbids comparison between pointer and integer". and in decryption, debut does not complete. I am just learning the program class. Might you help me?
In function 'int main(int, char**)':
18:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
28:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
41:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
41:23: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses] 42:13: error: expected ';' before '{' token
44:13: warning: second operand of conditional expression has no effect [-Wunused-value] 44:13: warning: third operand of conditional expression has no effect [-Wunused-value]
You should learn to read the error messages and include them with your questions. I'll do it for you this time.
You need to dereference the pointers in each of the lines mentioned 18, 28 and 41. Look it up.
Line 41 is wrong e|d is not the way to do what you are trying to do. And I think you are missing an 'if'.
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
string str;
getline(cin, str);
for (int i = 3; i < str.length(); i+=4) cout << str[i];
cout << endl;
}