#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
#include <sstream>
#include <ctime>
usingnamespace std;
int main()
{
setlocale(LC_ALL, "");
int x;
int end = 1;
long rows;
int number [7];
srand ((unsigned)time (NULL));
string answer;
while(end==1)
{
cout << "Welcome to the lottery!" << endl;
cout << "How many rows did you pay for?? ";
cin >> rows;
if(rows < 13)
{
cout << "Alright, here's your tip!" << endl;
while(rows > 0)
{
x = 1;
while(x <= 7)
{
int number[] = {rand()%35 + 1};
cout << number[] << " ";
x++;
}
cout << endl;
rows--;
}
}
else
{
cout << "Only 1-12 rows are allowed!" << endl;
}
cout << "Continue? (Yes/No) ";
char temp[256];
cin >> temp;
strupr(temp);
svar = temp;
if(svar == "YES")
{
cout << "Okay!" << endl;
system("cls");
}
elseif (answer == "NO" || answer != "NO")
{
end = 0;
}
}
system("pause");
return 0;
}
You see where the rand is on row 32 I want one random number in each of the 7 reserved spaces in number[] in the interval of 1-35 using the rand function. How? I don't understand... Please don't direct me to another website because they don't explain. Any if there's anything with the variables it's my fault because i translated them from Swedish to English so I've might have missed one.
I pretty sure you should get rid of '[]'. Fix the remaining syntax errors, and show everybody your output.
But you want to write all generated values into an array right?
No. This is a temp variable so all data will be destroyed when a program-loop's been finished.
Or use global variable. If you want to access data, you'll need to define an array again.