What can i do here?

closed account (9wX36Up4)
#include<iostream>
#include<fstream>

using namespace std;

int zarat(int,int);

int zarat(int z1,int z2){
      int a,z1,z2;
      char zarlar;
      
      fstream Kaynak;
      Kaynak.open("Kaynak.txt",ios::in|ios::out);
      if(Kaynak.is_open()){
          cout<<"Push Z to Dice"<<endl;
          cin>>zarlar;
          if(zarlar=='Z'||zarlar=='z'){
              Kaynak>>a;
              srand(a);
              z1=1+(rand()%6);
              z2=1+(rand()%6);
              cout<<"First Dice :"<<z1<<endl<<"Second Dice :"<<z2<<endl;
              }
          else{
              cout<<"Only Z Button"<<endl;
              return zarat(z1,z2);
              }
          }
      else{
          cout<<"File Error"<<endl;
          return 0;
          }
}

int main(){
    char s,d;
    int i;
    
    cout<<"For to Start Dice Push A Button"<<endl;
    cin>>s;
    if(s=='a'||s=='A'){
        for(i=1;i<=1000;i++){
            cout<<"To Dice Please Push Z"<<endl;
            cin>>d;
            if(d=='Z'||d=='z')
                zarat(z1,z2);
            else
                cout<<"Only Z can Dice"<<endl;
                
        }
        }
    else{
        cout<<"Please for to Start Push A Button"<<endl;
        return main();
        }
}

I don't know what is wrong here please help me it gives mistake about int zarat
You did not delcare z1 and z2 in main but you passed z1 and z2 to the zarat function from main. You only need to declare variables once when you pass them to other functions so either declare and initialize z1 and z2 in main or just call zarat() from main and declare z1 and z2 there.
I hope that makes sense. Good luck!

What are the compile errors???

One problem I see is the start of the following function, your passing in z1 and z2 and your also declaring them locally. Delete the local ones. You also don't have z1 and z2 defined in main.

1
2
int zarat(int z1,int z2){
      int a,z1,z2;
closed account (9wX36Up4)
thank u both i solved the problem and learn one more thing
Topic archived. No new replies allowed.