Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,424 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,351 people online right now. Registration is fast and FREE... Join Now!




compilation time of a program

 
Reply to this topicStart new topic

compilation time of a program, giving error

avinandanaot
15 Oct, 2008 - 06:39 AM
Post #1

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 13


My Contributions
CODE
#include <process.h>
#include <iostream.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>

int main(int argc,char *argv[])
{
clock_t start,end;
FILE *fp;
int j;
char bb = 'f';
float var;
char aa[45]="The time that complies the program is : ";

cout << "Command line arguments:\n\n";
for (int i = 0; i < argc; ++i)
{
    cout << "Argument [" << i << "] : " << argv[i] << '\n';
}
   cout << "Measuring the time that needs to comply program ["
    << argv[i-1] << ".cpp" << ']' << "\n\n";


for(j=0;j<argc;++j)
{
    if((argv[j][0]=='-') && (argv[j][1]=='o'))
   {
      fp=fopen(argv[j+1],"w");
      bb = 't';
    }
   if((argv[j][0]=='b') && (argv[j][1]=='c') && (argv[j][2]=='c'))
      argv=argv+j;
}


start = clock();

int result = spawnvp(P_WAIT,"bcc",argv);

end = clock();
var = (end - start) / CLK_TCK;

if (bb == 't')
{
    fprintf(fp,"%s",aa);
    fprintf(fp,"%8.3f %s",var,"second(s)");
   fclose(fp);
}

if ((result != -1) && (bb != 't'))
{
    cout << "The time that complies the program is : "
     << var << " second(s)" << '\n';
}

if (result == -1)
{
    perror("execution error");
}

return result;
}


Mod edit - Please code.gif
~BetaWar
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Compilation Time Of A Program
15 Oct, 2008 - 07:02 AM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,022



Thanked: 81 times
Dream Kudos: 1175
My Contributions
What error are you recieving?
User is offlineProfile CardPM
+Quote Post

avinandanaot
RE: Compilation Time Of A Program
15 Oct, 2008 - 07:05 AM
Post #3

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 13


My Contributions
Call to undefined function 'spawnvp' in function main(int,char * *)

User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Compilation Time Of A Program
15 Oct, 2008 - 07:10 AM
Post #4

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,022



Thanked: 81 times
Dream Kudos: 1175
My Contributions
If you are using VC 2005+ you will need to change that to _spawnvp
If you are on linux it isn't supported, however these functions are posix_spawn, and posix_spawnp.

Hope that helps.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 01:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month