Return a string on function...

I think it might be a problem with my compiler. I dosn't like running this code on G++, and I want to see if I've done something wrong. The error I'm getting is:
Line 7: 'code' was not declared in this scope
Line 8: expected '.' or ';' before '{' token.
Line 17: expected primary-expression before '.' token
Line 22: 'decode' cannot be used as a function.
I'm only a bare-bones beginner, so if there are a lot of errors in my code please point them out to me.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  //Binary decoder... WOO
#include <iostream>
#include <string>

using namespace std;

string decode(code)
{
    return code;
}

int main()
{
    string code;
    cout << "Binary decoder, this is just a test.\n\nPlease input your binary code.";
    cin >> code;
    if ((string.size(code)%8)!=0);
    {
        cout << "This binary code is invalid.\n\n";
        main();
    }
    string text = decode(code);
}
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  //Binary decoder... WOO
#include <iostream>
#include <string>

using namespace std;

string decode(string code) //<--
{
    return code;
}

int main()
{
    string code;
    cout << "Binary decoder, this is just a test.\n\nPlease input your binary code.";
    cin >> code;
    if ((code.size() % 8)!=0); // <--
    {
        cout << "This binary code is invalid.\n\n";
        main();
    }
    string text = decode(code);
}
Well, thanks mate! Appreiciated!
Topic archived. No new replies allowed.