Thursday, July 30, 2009

Need help with a C++ program please?

ok I wrote something not sure how right it is but i do need some help on it


here is what i have:


int menu(int x){


cout%26lt;%26lt;"Press 1 to encrypt, 2 to decrypt, 3 to quit)"%26lt;%26lt;endl;


cin%26gt;%26gt;x;


return x;


}


void encrypt(char letter){


cout%26lt;%26lt;"Enter a message to encrypt"%26lt;%26lt;endl;


cin%26gt;%26gt;letter;


while (letter!='!'){


if (letter=='k') cout%26lt;%26lt;"1 ";


then 26 more if statements for letters


cin%26gt;%26gt;letter;


}


return;


}











void decrypt(int code){


cin%26gt;%26gt;code;


while (code!=0){


if (code==1) cout%26lt;%26lt;"k";


26 more if statements


cin%26gt;%26gt;code;


}


return;


}














int main(){





int choice;


int shift = 7; // default shift


choice = menu();************


while (choice != 3){


if (choice == 1){


cout %26lt;%26lt; "Enter the 'shift' value: ";


cin %26gt;%26gt; shift;


encrypt(shift); }


else


decrypt();************





cout%26lt;%26lt;endl%26lt;%26lt;endl%26lt;%26lt;endl;


choice = menu(); **********


}


return 0

Need help with a C++ program please?
Your function menu() does not take zero arguments. It need one argument, as per the function definition. What you want is


int menu(),





and what you have done is





int menu(int x)





And you are not using this parameter x at all.
Reply:Surely: your menu() function requires int as an argument.


Check you code thoroughly :-)


No comments:

Post a Comment