ceaser cypher

i'm having trouble with this homework assignment. it's not compiling and it's also having other issues. any help would be awesome

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <string.h>
using namespace std;
void revceaser (char str1[80])
{
	int i =0;
	while(i<strlen(str1)){
        str1[i] = int(str1[i]) - 3;
        i++;
	}
	cout << "Reverse Ceaser CIPHER" ;
	cout << str1<<endl;
}

void ceaser (char str1[80])
{
	int i =0;
	while(i<strlen(str1)){
        str1[i] = int(str1[i]) + 3;
        i++;
	}
    cout << "Ceaser CIPHER";
	cout << str1<<endl;
}

void reverse(char str[80])
{
    cout << "reverse cypher";
    int length = strlen(str);)
    for(int i>=0; i<=length-1; --)
        cout<<str[i];
    cout<<endl;
}


void rereverse(char str1[80])
{
    cout << "Decrypt Reverse CIPHER" ;
    int length = strlen(str1);
    for(int i=0; i<=length; i++)
        cout<<str1[i];
    cout<<endl;
}
int main()
{
    
    char str1[80];
    
    int i=0;
    
	cout << "Enter The Message to Encrypt?";
	cin.get(str1, 80);
	ceaser(str1);
	reverse(str1);
	revceaser(str1);
	rereverse(str1);
    
	getchar();
	system("PAUSE");
}

You have a superfluous ')' on your declaration line in reverse. Your compiler should have pointed that out.
when i take that out it still gave me an error on the line underneath that said "expected expression" and there were also some semantic issues
Many programmers read those errors and then fix them in their code.

for(int i>=0; i<=length-1; --)
This is horrific.

http://www.cplusplus.com/doc/tutorial/control/
Last edited on
I didn't even see that. I zeroed in on the first syntax error and skipped everything else.
Topic archived. No new replies allowed.