This is a program that I've been working on for a school project of mine.I'm getting an error that I don't really understand.I'm using Bloodshed Dev-C++ 4.9.9.2 and the error I'm getting is "In function 'voidCaesar()' too many arguments to function 'int esteLitera()' at this point in file"(referring to line 55).
#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<stdio.h>
using namespace std;
void afisareMeniu();
void criptCaesar();
void criptMansfield();
void decriptTranspozitie();
int esteLitera(char);
#define CRIPTCAESAR 1
#define CRIPTMANSFIELD 2
#define DECRIPTTRANSPOZITIE 3
#define IESIRE 4
int main()
{
int nrOptiune;
for(;;){
afisareMeniu();
std::cout<<endl<<"\n\n\n";
cin>>nrOptiune;
if(nrOptiune==CRIPTCAESAR)criptCaesar();
if(nrOptiune==CRIPTMANSFIELD)criptMansfield();
if(nrOptiune==DECRIPTTRANSPOZITIE)decriptTranspozitie();
if(nrOptiune==IESIRE)break;
}//for
return 0;
}//int main
void afisareMeniu()
{
system("cls");
cout<<"\n Proiect Programarea Calculatoarelor"<<endl<<"Calculatoare 1.1.1";
cout<<"\n\n 1.Criptare Caesar"<<endl;
cout<<"\n\n 2.Criptare Mansfield"<<endl;
cout<<"\n\n 3.Decriptare prin transpozitie cu 2 jumatati"<<endl;
cout<<"\n\n 4.Iesire"<<endl;
}
void criptCaesar()
{
system("cls");
cout<<"\n\n Ati ales criptare Caesar"<<endl;
char s1[100];
char s2[100];
cout<<"\n\n Introduceti textul pentru criptare"<<endl;
cin.get();
cin.get(s1,100);
strupr(s1);
int L=strlen(s1);
int i;
for(i=0;i<L;i++)
if(esteLitera(s1[i]==1)){
if(s1[i]=='X')s2[i]='A';
else if(s1[i]=='Y')s2[i]='B';
else if(s1[i]=='Z')s2[i]='C';
else s2[i]=s1[i]+3;}
else s2[i]=s1[i];
cout<<"Textul criptat este: "<<s2<<endl;
cout<<"Apasati o tasta pentru a reveni la meniu.";
getch();
}
void criptMansfield()
{
system("cls");
int i,j,k,x=0;
char rez[200],c[100];
char a[5]={'A','E','I','O','U'};
char b[5]={'A','E','I','O','U'};
char p[5][5]={'A','B','C','D','E',
'F','G','H','I','J',
'K','L','M','N','O',
'P','R','S','T','U',
'V','W','X','Y','Z' } ;
cout<<" "<<"Criptare Mansfield"<<endl<<endl;
cout<<"Introduceti textul pentru criptare:";
cin.get();
cin.get(c,100);
strupr(c);
for ( k=0;k<strlen(c);k++ )
if ((c[k]>='A')&&(c[k]<='Z'))
for ( i=0;i<=4;i++ )
for ( j=0;j<=4;j++ )
if ( c[k]==p[i][j] ){rez[x]=a[i];
x++;
rez[x]=b[j];
x++;}
else;
else{rez[x]=c[k];
x++;}
rez[x]=0;
cout<<rez;
getch();
}
void decriptTranspozitie()
{
system("cls");
char s[101],x[51],y[51];
int i,j,optiune;
cout<<"Decriptare transpozitie cu doua jumatati"<<endl<<endl;
cout<<"Dati textul pentru decriptat:";
cin.get();
cin.get(s,100);
strupr(s);
if(strlen(s)%2==0){
for(i=0;i<strlen(s);i+=2)
cout<<s[i];
for(j=1;j<strlen(s);j+=2)
cout<<s[j];
}
else if(strlen(s)%2!=0){
for(i=0;i<strlen(s);i+=2)
cout<<s[i];
for(j=1;j<strlen(s);j+=2)
cout<<s[j];
cout<<s[j]; }
cout<<"\n\n\nPentru a reveni la meniu apasati tasta 1!\n";
cin>>optiune;
switch (optiune)
{case (1) : { afisareMeniu(); break; } }
}
int esteLitera(char x)
{
if((x>='A')&&(x<='Z'))
return 1;
else return 0;
}
Your declaration of esteLitera
is wrong. You declare the function as
int esteLitera();
Then you try to call it with an argument. Change the declaration to
int esteLitera(char);
Also, you´re calling esteLitera
with a boolean argument, not a char:
if(esteLitera(s1[i]==1)){
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.