I can’t implement the output of one word on the screen, there will be a lot of words and I need to store them somewhere and from this storage, at the touch of a button, output one random word. Please help me.
Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants user194374, aleksandr barakin , αλεχολυτ , fori1ton , Kromster July 5 '16 at 7:44 .
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
- I propose to cram into the sqlite table. From there, take the number of records in the table and take the generator by a unique number or in order - maint
- Very much - how much? In principle, the vocabulary of any language fits easily into the memory of any modern smartphone. - andy.37
- Not much, I think, 1,500 words is maximum. - Tokiwartoot
|
1 answer
Store in sqlite, and using the rand function, select a random number within the total number of words. And display by ordinal number or as you prefer.
rand() % 10 + 1; //От 1 до 10 Update:
- I tried to use rand, but it gives out a random number once, after the first number, no matter how much I run, the program will also be a number. I tried to make a srand with a time dependence, but there it is not quite a random number that gives out - Tokiwartoot
- @Tokiwartoot immediately after launching the program, make
srand(time(0));then at each start there will be different random numbers. - Alexander - If we bring a normal link, then bring the code from it (I’m talking about the first one).
randnot recommended for use, because is an extremely bad generator. - ixSci - There is an example of why duplicate - Vladimir VSeos
|