So I am currently learning C, and I have some confusion about how the random()
function works. I know I have to provide a seed, but I don’t know how to actually generate the random number.
srandom(seed); long int value= random(40);
When I try this it gives me a compiler error:
too many arguments to function ‘long int random()
The end goal is to get a random number between 1 and 40. I should add that the goal is to not use the rand()
function.
Related Posts:
- How to generate a random int in C?
- Random number between 0 and 1 in python [duplicate]
- How to randomize Excel rows
- Random / noise functions for GLSL
- Java: Variable is already defined in method
- Implementing Taylor Series for sine and cosine in C
- pthread_join() and pthread_exit()
- strdup() – what does it do in C?
- Why should we typedef a struct so often in C?
- Undefined reference to pthread_create in Linux
- dereferencing pointer to incomplete type
- What does \0 stand for?
- Expression must be a modifiable L-value
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- What is the significance of return 0 in C and C++?
- Generating a Random Number between 1 and 10 Java
- How do I use valgrind to find memory leaks?
- Generating a Random Number between 1 and 10 Java [duplicate]
- How do I generate random integers within a specific range in Java?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- munmap_chunk(): invalid pointer
- What is the LD_PRELOAD trick?
- What is the argument for printf that formats a long?
- Using %s in C correctly – very basic level
- How to get a random number between a float range?
- Fastest JSON reader/writer for C++
- What is the difference between const int*, const int * const, and int const *?
- How to create my own header file in c++?
- Is there a function to copy an array in C/C++?
- C error: Expected expression before int
- Returning string from C function
- Char Comparison in C
- How to randomize (shuffle) a JavaScript array?
- C – The %x format specifier
- What does it mean to write to stdout in C?
- what is the unsigned datatype?
- Examples of good gotos in C or C++
- Reading a string with scanf
- getopt_long() — proper way to use it?
- C read file line by line
- Generate random float between two floats
- C read file line by line
- Copying a part of a string (substring) in C
- Incompatible implicit declaration of built-in function ‘malloc’
- expression must have integral type
- Quick Way to Implement Dictionary in C
- gdb: “No symbol table is loaded”
- Going through a text file line by line in C
- How to use glOrtho() in OpenGL?
- Reversing a string in C
- When a number is written as 0x00… what does the x mean
- How to remove the character at a given index from a string in C?
- waitpid, wnohang, wuntraced. How do I use these
- Convert C program into assembly code
- C: error: expected ‘)’ before ‘;’ token
- execv vs execvp, why just one of them require the exact file’s path?
- difference between
and - Writing binary number system in C code
- What are 0x01 and 0x80 representative of in C bitwise operations?
- Convert char array to string use C
- How to make parent wait for all child processes to finish?
- Use of cudamalloc(). Why the double pointer?
- OpenGL — GL_LINE_LOOP —
- Valgrind complains with “Invalid write of size 8”
- How to print an unsigned char in C?
- Read and write to binary files in C?
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- Difference between sizeof(char) and sizeof(char *)
- How to empty a char array?
- Undefined reference to main – collect2: ld returned 1 exit status
- What does ** mean in C?
- Is there a way to have printf() properly print out an array (of floats, say)?
- How do you allow spaces to be entered using scanf?
- How can I do GUI programming in C?
- Preventing console window from closing on Visual Studio C/C++ Console application
- What is the proper equivalent of “while(true)” in plain C?
- How do I compile the asm generated by GCC?
- What is the difference between %g and %f in C?
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- Structure padding and packing
- Implementation of strtok() function
- C fopen vs open
- switch case: error: case label does not reduce to an integer constant
- warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
- Simple Coin Toss using random class in Java. The do while loop doesn’t seem to generate random results
- warning: return makes pointer from integer without a cast but returns integer as desired
- Dynamic vs static array in c
- Suggestions needed: Effective Java to C source code converter
- The difference between char * and char[] [duplicate]
- How to clear input buffer in C?
- Generate a random letter in Python
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- Implicit function declarations in C
- Convert long long to string in C?
- how to stop a loop arduino
- How to normalize a mantissa
- Best way to randomize an array with .NET
- How to use shared memory with Linux in C
- When is it ok to use a global variable in C?
- lvalue required as increment operand