-7

これは私のコードです。何らかの理由で、すべてを宣言したにもかかわらず、宣言されていない識別子があると主張しています

#include <iostream>
#include <string>
#include <fstream>
#include <iterator>
#include <algorithm>

using namespace std;

char a;
char caesarCipher (char );
char caesarDecipher (char );
string input;
string line;
std::string str;

void displayMenu() { 
    cout<<"This program will encrpt/decrypt files";
    cout<<"To encrypt press 'e'/To decrypt press 'd'";
    cin>>a;
}

void encrypt() { 
    string filename,ofilename;          
    cout << "Input filename: ";
    cin >> filename;
    cout << "Output filename: ";
    cin >> ofilename;

    ifstream infile(filename);
    ofstream outfile(ofilename);
    if ((infile >> noskipws) && outfile) {
        std::transform(istream_iterator<char>(infile),
                       istream_iterator<char>(),
                       ostream_iterator<char>(outfile),
                       ceaserCipher);

        string output = "";
        for(int x = 0; x < input.length(); x++) {
            output += ceaserCipher(input[x]);
        }
    }
}

/**************************************************************
* This function decrypts the content of infile and saves the *
* decrypted text into outfile *
* @param infile string (file that has encrypted text) *
* @param outfile string (file that will have decrypted text) *
**************************************************************/
void decrypt() { 
    string filename,ofilename;          
    cout << "Input filename: ";
    cin >> filename;
    cout << "Output filename: ";
    cin >> ofilename;

    ifstream infile(filename);
    ofstream outfile(ofilename);
    if ((infile >> noskipws) && outfile) {
        std::transform(istream_iterator<char>(infile),
                       istream_iterator<char>(),
                       ostream_iterator<char>(outfile),
                       ceaserDecipher);

        string output = "";
        for(int x = 0; x < input.length(); x++) {
            output += ceaserDecipher(input[x]);
        }
    }
}

/**************************************************************
* This function takes an character and a cipher key to return*
* an encrypted character. *
* @param c is a char (the character to be encrypted) *
* @param key is an integer (cipher key given in the handout) *
**************************************************************/
char ceaserCipher(char c) {
    if (isalpha (c)) {
        c = toupper(c);
        c = (((c-65)+5) % 26) + 65;
    }
    return c;
}

char ceaserDecipher(char c) {

    if (isalpha (c)) {
        c = toupper(c);
        c = (((c-65)-5) % 26) + 65;
    }
    return c;
}

int main() {
    char b;

    displayMenu();
    if (a=='e'||a=='E') {
        encrypt;
    }
    else (a=='d'||a=='D'); { 
        decrypt;
    }

    cout<<"To exit input 'e'/To continue press 'c'";
    cin>>b;
    switch (b) {
    case 'c':
        return main();

    case 'e':
        return 0;
        break;
    }
}

エラーは次のとおりです。

LooserCipher' : 宣言されていない識別子
LooserCipher': 識別子が見つかりません
LooserDecipher' : 宣言されていない識別子
LooserDecipher': 識別子が見つかりません

ありとあらゆる助けに感謝します

4

2 に答える 2

3

関数名のスペルが間違っています。あなたが持っている

char caesarDecipher (char );

使用しようとしている間(および後で定義する間)ceaserDecipher(スペルの異なる方法に注意してください:「ceasEr」と「ceasAr」)。

于 2013-04-03T14:52:17.040 に答える
2

あなたの前方宣言はそれをシーザーと綴りますが、関数定義はそれをシーザーと綴ります。

于 2013-04-03T14:52:18.263 に答える