samedi 16 mai 2015

How to put a random number into an array then a text file

So what i am trying to do is put a random number generator from one thru ten into an array that is has 50 elements and then put that into a text file. My problem is that the code I have written for the code and generator has an error and I can't wrap my head around how to get it into a text file.

 #include<iostream>
 #include<ctime>
    void CreateFile();
    void printFunc(int[]);
    void FillFunc(int[]);

    void CreateFile()
    {
        int random[50]; //Array that is 0-50

            srand((unsigned)time(NULL));
            fillFunc(random);
            printFunc(random);

            return 0;
    }
    void fillFunc(int arr[])
    {
            for (int i = 1; i < 50; i++)
            {
                    arr[i] = 1 + rand() % 10;
        }

    }

    void printFunc(int arr[])
    {
        for (int i = 1; i < 50; i++)
        {
                cout << arr[i];
        }
    }




Aucun commentaire:

Enregistrer un commentaire