Hello everyone, me and my friend just finished writing up this code with some help from our professor. We fixed some of the errors but it still wont start up, I'm using Microsoft visual C++ to run the program.
Well we hit a dead end and are struggling if anyone can help us that would be much appreciated!
Please and thank you.
//Author: Main Answer
#include <iostream>
#include <string>
usingnamespace std;
//Prototypes which hold the function of encrypt and decrypt
void encrypt(string x);
void decrypt(string x);
int main(){
//Variable needed to store user's input
string input0;
string input1;
//Prompt the user to input a message and then calls the ecryption function
cout << "Enter Your Message: ";
getline(cin,input0);
encrypt(input0);
//You can guess lol
cout << endl;
//Prompt the user to input the code and then calls the decryption function to convert back to message
cout << "Enter the code: ";
getline(cin,input1);
decrypt(input1);
}
//The encryption function itself
void encrypt(string x){
//Variables meant to store the asking number and the individual character (Max 128)
int ascii[128];
string code[128];
//Variables meant to dynamically enhance the asking numbers and to keep track of loop for reset
int j = 1;
int t = 0;
//Loop for enhancing the asking numbers
for(unsignedint i = 0; i < x.length(); i++){
ascii[i] = static_cast<int>(x[i]) + j;
j++;
t++;
if(t == 16 ){
j = 1;
t = 0;
}
}
//Loop for converting the asking numbers to characters
for(unsignedint i = 0 ; i < x.length(); i++){
code[i] = static_cast<char>(ascii[i]);
cout << code[i];
}
cout << endl;
}
//The decryption function itself
void decrypt(string x){
//Variables meant to store the enchance asking number and the individual character (Max 128)
int Eascii[128];
string code[128];
//Variables meant to dynamically enhance the asking numbers and to keep track of loop for reset
int j = 1;
int t = 0;
//Loop for reversing the enhance asking numbers
for(unsignedint i = 0; i < x.length(); i++){
Eascii[i] = static_cast<int>(x[i]) - j;
j++;
t++;
if(t == 16 ){
j = 1;
t = 0;
}
}
//Loop for converting the asking numbers to characters
for(unsignedint i = 0 ; i < x.length(); i++){
code[i] = static_cast<char>(Eascii[i]);
cout << code[i];
}
cout << endl;
}
This code runs, I've copy, pasted and confirmed that. If you are using MSVS then don't you need to include that "stdafx.h" header? If not, then what error is it throwing back at you?