how to printing cout to file instead of console or taking argv before main function [closed]

  argv, c++, ofstream, printing
my code

ofstream fout("output.txt");
class Cards{
public:
char suit;
int number;
int visibilty;
public:

Cards(){
    number=0;
    suit='A';
    visibilty=0;
};
Cards(char suitName, int suitNumber, int cardVisibility){
suit=suitName;
number=suitNumber;
visibilty=cardVisibility;
}

//class function

virtual void printIt(){
    if(number<10&&visibilty==1&&suit!='A')
        fout << Cards::suit << 0<<Cards::number;
    else if(number>=10&&visibilty==1&&suit!='A'){
        fout << Cards::suit << Cards::number;
    }
    else if(suit=='A'){
        
    }
    else
        fout<<"@@@";
}

//creating cards array

Cards cards[52];
Cards stock[24];
Cards waste[24];
Cards tempWaste[3];
Cards foundation[4];
Cards pile[7][20];

//fill array empty card

void fillArray(Cards theArray[], int sizeOfArray){
    for(int i=0;i<sizeOfArray;i++){
        theArray[i]=Cards();
    }
};

//main function

int main(int argc, const char * argv[]) {
Cards card=Cards();
fout<<"My cards"<<endl;
card.printingIt();

}

I want to print these to the file I received with argv, but it gives an error because I cannot access argv without running main. how do i hang this problem.

Source: Windows Questions C++

LEAVE A COMMENT