home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11818 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.4 KB  |  55 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!uunet.ca!cognos!alanm
  3. From: alanm@cognos.com (Alan Myrvold)
  4. Subject: Re: HELP
  5. Message-ID: <1992Jul31.163558.15163@cognos.com>
  6. Organization: Cognos Incorporated, Ottawa CANADA
  7. References: <1992Jul30.154323.12491@cc.umontreal.ca>
  8. Date: Fri, 31 Jul 1992 16:35:58 GMT
  9. Lines: 44
  10.  
  11. In article <1992Jul30.154323.12491@cc.umontreal.ca> mikhail@ERE.UMontreal.CA (Mikhail Ossama) writes:
  12. >Bonjour
  13. >SVP le programme suivant ne marche pas ..
  14. >je sais que vous etes occuper mais SVP essayer de m'aider ..
  15. >Merci.
  16.  
  17. Comme ca, peut-etre?
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. main(int argc, char *argv[])
  23. {
  24.    char *cmd_buffer;
  25.  
  26.    if (argc!=4) { 
  27.       printf("Usage : ./link prog.f -o prog.exe \n");
  28.       exit(0); 
  29.    }
  30.  
  31.    /* allocate a large enough buffer */
  32.    cmd_buffer = (char *) malloc(strlen(argv[1])+strlen(argv[3])+100);
  33.    if (!cmd_buffer) {
  34.       printf("Out of memory!\n");
  35.       exit(0); 
  36.    }
  37.    
  38.    /* construct the command */
  39.    sprintf(cmd_buffer,
  40.       "f77 %s -o %s -L/usagers/garcia/gqopt/lib -lgq5 -lthomas -p",
  41.       argv[1],argv[3]);
  42.  
  43.    /* execute it */
  44.    system(cmd_buffer);
  45.  
  46.    /* not necessary to free, since program terminates here, but a good habit */
  47.    free(cmd_buffer);
  48. }
  49.  
  50. ---
  51. Alan Myrvold          3755 Riverside Dr.    
  52. Cognos Incorporated   P.O. Box 9707          alanm@cognos.com
  53. (613) 738-1440 x3317  Ottawa, Ontario       
  54.                       CANADA  K1G 3Z4       
  55.