Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3141 connectés 

 


Dernière réponse
Sujet : [C] C++ Builder ...
paranoidandroid

os2 a écrit a écrit :

tu peux afficher ton script ici  




 
 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#define SIZETAB 6
#define MAXCHAR 100
 
char *tables[SIZETAB];
char input_f[30];
char output_f[30];
char *cmdd;
char *cmdf;
char *command;
void launch_bat();
void help(void);
void writefile(char *mot);
char *insert(char *table);
 
void read(char *fichier)
{
 FILE *fic;
 FILE *sortie;
 char temp[32];
 char *cmd;
 int j;
 int i=0;
 
 
 fic = fopen(fichier,"r" );
 
  if(fic != NULL)
  {
   do
    {
     fscanf(fic, "%s", temp);
     tables[i]=malloc(strlen(temp)*sizeof(char));

 

    strcpy(tables[i],temp);
     i++;
    }
   while(!feof(fic));
     //Pour se situer reelement a la derniere ligne
     i--;
   fclose(fic);
     sortie = fopen("greptables.bat","a" );
 
     if(sortie != NULL)
       {
       for(j=0;j<i;j++)
        {
      cmd = malloc(50*sizeof(char));
         strcpy(cmd,insert(tables[j]));
         fputs(cmd, sortie);
                 free(tables[j]);
            free(cmdf);
      free(cmdd);
      free(command);
        }
       fclose(sortie);
 
         }
 
  launch_bat();
 
 
     }
 else printf("le fichier %s n'a pas pu etre ouvert",input_f);
}
 
void launch_bat(void)
{
 system("greptables.bat" );
}
 
char *insert(char *table)
{
 char *cmd;
 char *separateur = "/";
 int dbt;
 int fin;
 int var;
 
 command=malloc(50*sizeof(char));
 
 strcpy(command,"grep -i -l -c -d / *.* >> ResultatGrep.txt\n" );
 cmdd = strtok(command,separateur);
 cmdf = strtok(NULL,"" );
 dbt = strlen(cmdd);
 fin = strlen(cmdf);
 var = strlen(table)+1;
 
 cmd=malloc((var+fin+dbt)*sizeof(char));
   sprintf(cmd,"%s%s%s",cmdd,table,cmdf);
 
 return(cmd);
}
 
void help(void)
{
 printf("Correct syntax is :\n list <input.file> <output.file>" );
}
 
void main(int argc, char *argv[])
{
 //argc = 3;
        //argv[1]="liste.txt";
        //argv[2]="result.txt";
 
 if (argc != 3) help();
 else
 {
   strcpy(input_f,argv[1]);
   strcpy(output_f,argv[2]);
   read(input_f);
 }
}


Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
paranoidandroid

os2 a écrit a écrit :

tu peux afficher ton script ici  




 
 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#define SIZETAB 6
#define MAXCHAR 100
 
char *tables[SIZETAB];
char input_f[30];
char output_f[30];
char *cmdd;
char *cmdf;
char *command;
void launch_bat();
void help(void);
void writefile(char *mot);
char *insert(char *table);
 
void read(char *fichier)
{
 FILE *fic;
 FILE *sortie;
 char temp[32];
 char *cmd;
 int j;
 int i=0;
 
 
 fic = fopen(fichier,"r" );
 
  if(fic != NULL)
  {
   do
    {
     fscanf(fic, "%s", temp);
     tables[i]=malloc(strlen(temp)*sizeof(char));

 

    strcpy(tables[i],temp);
     i++;
    }
   while(!feof(fic));
     //Pour se situer reelement a la derniere ligne
     i--;
   fclose(fic);
     sortie = fopen("greptables.bat","a" );
 
     if(sortie != NULL)
       {
       for(j=0;j<i;j++)
        {
      cmd = malloc(50*sizeof(char));
         strcpy(cmd,insert(tables[j]));
         fputs(cmd, sortie);
                 free(tables[j]);
            free(cmdf);
      free(cmdd);
      free(command);
        }
       fclose(sortie);
 
         }
 
  launch_bat();
 
 
     }
 else printf("le fichier %s n'a pas pu etre ouvert",input_f);
}
 
void launch_bat(void)
{
 system("greptables.bat" );
}
 
char *insert(char *table)
{
 char *cmd;
 char *separateur = "/";
 int dbt;
 int fin;
 int var;
 
 command=malloc(50*sizeof(char));
 
 strcpy(command,"grep -i -l -c -d / *.* >> ResultatGrep.txt\n" );
 cmdd = strtok(command,separateur);
 cmdf = strtok(NULL,"" );
 dbt = strlen(cmdd);
 fin = strlen(cmdf);
 var = strlen(table)+1;
 
 cmd=malloc((var+fin+dbt)*sizeof(char));
   sprintf(cmd,"%s%s%s",cmdd,table,cmdf);
 
 return(cmd);
}
 
void help(void)
{
 printf("Correct syntax is :\n list <input.file> <output.file>" );
}
 
void main(int argc, char *argv[])
{
 //argc = 3;
        //argv[1]="liste.txt";
        //argv[2]="result.txt";
 
 if (argc != 3) help();
 else
 {
   strcpy(input_f,argv[1]);
   strcpy(output_f,argv[2]);
   read(input_f);
 }
}

os2 tu peux afficher ton script ici
paranoidandroid je viens de terminer un petit script en C, où je me suis fais par certains d'entre vous...
 
Lorsque je compile, avec C++ Builder ( J'avais rien d'autres sous la main.. et lccwin32 Bugg grave chez moi ), il n'y a aucun warning, et aucune erreur.
 
si je lance mon exe, j'ai un problême de :

Project Project1.exe raised exception class EAccessViolation with message 'Access violation at adress 3256E5FB. Read of adress 642D2D05E'. Process stopped. Use Step or Run to continue.

 
Et ça ... bah ça apparait en mode déboggage arrivé à la fin du script ... Je dis bien à la fin du script, après la derniere accolade du main..
 
Qu'est ce que ça peut être ??
c'est la premiere fois que j'ai ça ...

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)