I have a function which can generate 10000 random numbers and write them in a file.
void generator(char filename[])              
{
    int i;
    int n;
    FILE* fp;
    if((fp=fopen(filename,"w+"))==NULL)
    {
        printf("Fail creating file!");
    }
    srand((unsigned)time(NULL));
    for(i=0;i<10000;i++)
    {
        n=rand()%10000;
        fprintf(fp,"%d ",n);
    }
    fclose(fp);
}
How can I get the execution time of this function using C/C++ ?
 
     
     
     
     
     
    