I'm getting this error message
Info :Compiling G:\Encryption\version21.cpp
Error: version21.cpp(119,11):Case bypasses initialization of a local variable
How can i fix it
Heres the code:Not finished tho)
Code:
//By:Nick Johnson
//version 1.1
#include <fstream.h>
#include <conio.h>
#include <iomanip.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
char user[256];
char input_file[60];
int choice;
void input(int&choice);
void process(int&string_length, int&key,int&user_choice,int&key2);
ifstream infile;
int main()
{
clrscr();
int user_choice,string_length;
int key, key2;
cout<<"\n"<<setw(40)<<"\tEncryption\n\n";
input(choice);
process(string_length,key,user_choice,key2);
return 0;
}
void input()
{
cout<<"\t\t\t ************************** "<<endl;
cout<<"\t\t\t * 1. Encrypt a nonfile * "<<endl;
cout<<"\t\t\t * 2. Encrypt a file * "<<endl;
cout<<"\t\t\t * 3. Decrypt a file * "<<endl;
cout<<"\t\t\t * 4. Exit * "<<endl;
cout<<"\t\t\t ************************** "<<endl;
cout<<"\nEnter your choice: ";
cin >>choice;
}
void process(int&string_length,int&key,int&user_choice,int&key2)
{
switch(choice)
{
case 1:
clrscr();
cout<<"Enter something you want to encrypt: "<<endl;
cin.ignore(80, '\n');
cin.get(user, 256);
cin.ignore(80, '\n');
string_length=strlen(user);
cout<<"\nEnter key: ";
cin>>key;
for(int x=0; x<string_length; x++)
{
user[x]=user[x]+key;
}
key2=123456789;
for(int f=0; f<string_length; f++)
{
user[f]=user[f]+key2;
}
cout<<"\nEncrypted: "<<endl;
cout<<user<<endl;
clrscr();
cout<<"Would you like to decrypt it?"<<endl;
cout<<"1 = yes / 0 = no"<<endl;
cin >>user_choice;
if (user_choice==1)
{
key=0;
cout<<endl;
cout<<"Enter the key: ";
cin>>key;
for(int x=0; x<string_length;x++)
{
user[x]=user[x]-key;
}
for(int f=0; f<string_length; f++)
{
user[f]=user[f]-key2;
}
cout<<"\nDecrypted: \n";
cout<<user;
cout<<endl;
}
else
{
clrscr();
cout<<"Thanks for trying my program" <<endl;
}
break;
case 2:
clrscr()
cout<<"Enter The Input File(C:\example.txt): ";gets(input_file);fflush(stdin);
cout<<input_file<<endl;
}
}
Also any suggestions on how to improve the code would cool
Thanks alot