Search code examples
c++crandomarc4random

arc4random in wxDev C++


im trying to add arc4random into my C console-based project.
Basically im including the .c file in my project and then a method call as:

    #include <stdio.h>
    #include <stdlib.h>
    #include "arc4random.c"



    //Define globals  
    int r;

    int main(int argc, char *argv[]) {  
    r = (arc4random() % 100);

    system("PAUSE");       
    return 0;
 }

Its pretty straight forward, except compiler gives me an error, what am I doing wrong?
Thanks,
Oliver.


Solution

  • Including C files is not a good practice in C programming, except in some cases with automatically-generated code.

    Instead, all the source files should be passed to the compiler and you should only include header files which contain function prototypes and type definitions.