Code::Blocks Forums

User forums => Help => Topic started by: Esemplastic on July 29, 2024, 07:58:24 am

Title: Help with code
Post by: Esemplastic on July 29, 2024, 07:58:24 am
Hello.
I have this code:

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

void printRandomDice(int amount) {
    srand(time(0));

    for (int i; i < amount; i++) {
        cout << (rand() % 6) + 1 << endl;
    }
}

int main()
{
    printRandomDice(5);
}


It works perfectly but the thing is that when I was writing "rand()" and "srand(time(0))", it didn't show autocomplete options for those functions. I really want to knw how i can get this fixed.
Title: Re: Help with code
Post by: Grit Clef on July 29, 2024, 11:27:28 am
Try a Nightly Build (https://forums.codeblocks.org/index.php/board,20.0.html) and use the code completion using Clangd (https://forums.codeblocks.org/index.php/topic,24357.0.html).
Title: Re: Help with code
Post by: stahta01 on July 29, 2024, 02:50:11 pm
To origin poster (OP): Please read https://forums.codeblocks.org/index.php/topic,9996.0.html (https://forums.codeblocks.org/index.php/topic,9996.0.html)

Tim S.
Title: Re: Help with code
Post by: Miguel Gimenez on July 30, 2024, 01:27:34 pm
Literal copy of a post (https://forums.codeblocks.org/index.php/topic,24625.msg168049.html#msg168049) from 2021.
Waiting for the spam link.