int a = srand(time(NULL));
The prototype for srand
is void srand(unsigned int)
(provided you included <stdlib.h>
).
This means it returns nothing … but you’re using the value it returns (???) to assign, by initialization, to a
.
Edit: this is what you need to do:
#include <stdlib.h> /* srand(), rand() */ #include <time.h> /* time() */ #define ARRAY_SIZE 1024 void getdata(int arr[], int n) { for (int i = 0; i < n; i++) { arr[i] = rand(); } } int main(void) { int arr[ARRAY_SIZE]; srand(time(0)); getdata(arr, ARRAY_SIZE); /* ... */ }
Related Posts:
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- Why should we typedef a struct so often in C?
- What is the difference between ++i and i++?
- Why does ENOENT mean “No such file or directory”?
- Floating point exception (core dumped)
- Stack smashing detected
- Openssl : error “self signed certificate in certificate chain”
- How to convert a string to integer in C?
- Get a substring of a char* [duplicate]
- What is the behavior of integer division?
- Difference between malloc and calloc?
- What is Bit Masking?
- What causes the Broken Pipe Error?
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- Bad File Descriptor with Linux Socket write() Bad File Descriptor C
- What is the difference between char s[] and char *s?
- Why use bzero over memset?
- What does “1e” mean?
- Warning comparison between pointer and integer
- The importance of c enumeration (typedef enum) [duplicate]
- What does #pragma once mean in C? [duplicate]
- Warning comparison between pointer and integer
- what is the meaning of == sign?
- What does “control reaches end of non-void function” mean?
- Printing long int value in C
- How do I use extern to share variables between source files?
- In C programming, what is `undefined reference`error, when compiling?
- warning: implicit declaration of function
- Process finished with exit code 11 | Error during malloc [duplicate]
- C read file line by line
- How does wait(NULL) exactly work?
- No Symbol Table using GDB on Compiled Programs
- Returning string from C function
- How do I create an array of strings in C?
- Char Comparison in C
- Is there a printf converter to print in binary format?
- What is a bus error? Is it different from a segmentation fault?
- Xcode – Warning: Implicit declaration of function is invalid in C99
- Converting a C program to MIPS
- what is the unsigned datatype?
- how to convert negative hexadecimal to decimal
- where does stdio.o live in linux machine?
- sizeof float (3.0) vs (3.0f)
- Understanding INADDR_ANY for socket programming
- How do I lowercase a string in C?
- What does “Size in TCHARs” means?
- The Definitive C Book Guide and List[
- conflicting types error when compiling c program using gcc
- Get the current time in C
- What’s the difference between a file descriptor and file pointer?
- What is a file with extension .a?
- What is the difference between exit(0) and exit(1) in C?
- Why is %c used in C?
- Cygwin – Makefile-error: recipe for target `main.o’ failed
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- Need more information about Aborted (core dumped)
- Does C have a “foreach” loop construct?
- What’s wrong with my code? What is argv[1]?
- Array definition – Expression must have a constant value
- How to print a char array in C through printf?
- Multiple definition of … linker error
- Zero an array in C code
- strcmp giving segmentation fault
- What does “pointer being freed was not allocated” mean exactly?
- (.text+0x20): undefined reference to `main’ and undefined reference to function
- strcmp not working
- Error: initializer element is not computable at load time
- Memory Clobbering Error
- Convert char array to string use C
- error: aggregate value used where an integer was expected
- warning: passing argument ’from incompatible pointer type [enabled by default]’
- Return a `struct` from a function in C
- Iterate through a C array
- How to simply convert a float to a string in c?
- How does one represent the empty char?
- Scanning Multiple inputs from one line using scanf
- Removing trailing newline character from fgets() input
- hash function for string
- xorl %eax – Instruction set architecture in IA-32
- Which of sprintf/snprintf is more secure?
- how use EOF stdin in C
- How does the strtok function in C work? [duplicate]
- Error: “Access not within mapped region at address” (Valgrind)
- Allocating char array using malloc
- Implementation of strtok() function
- warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
- typedef struct pointer definition
- How does the fscanf function work?
- Removing last character in C
- The code does not execute properly. Try to figure out why
- error: ISO C forbids nested functions – What’s wrong?
- Dereference void pointer
- What’s the difference between “mod” and “remainder”?
- What is char ** in C? [duplicate]
- undefined reference to `std::ios_base::Init::Init()’
- Carriage return in C?
- How to Compare 2 Character Arrays [duplicate]
- Difference between “while” loop and “do while” loop