I've created a list of strings and load a text file in it. once list is created, the program have to read it, do something and write results in a new text file.
ofstream f;
f.open("filename.txt");
string key;
list<string> text;
static char ALPH[21] = {'A','B','C','D','E','F','G','H','I','L','M','N','O','P','Q','R','S','T','U','V','Z'};
int* index_t = new int[text.size()];
int* index_k = new int[key.length()];
for(int i = 0; i < key.length(); i++){
for(int j = 0; j < 21; j++){
if(key[i] == ALPH[j])
index_k[i] = j;
}
}
for(list<string>::iterator it = text.begin(); it != text.end(); it++){
for(int i = 0; i < it->length(); i++){
for(int j = 0; j < 21; j++){
if((*it)[i] == ALPH[j])
index_t[i] = j;
}
char ch = ALPH[(index_k[i%key.length()] + index_t[i])%21];
f << ch;
}
f << "\n";
}
f.close();
I have not even tried to implement it because I already believe is wrong. someone tell me how to change it to be able to make it work?
thank you :confused: