diff --git a/mars_compile.c b/mars_compile.c new file mode 100644 index 0000000..b265ab5 --- /dev/null +++ b/mars_compile.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include"mars_types.h" /* importe les types utilisés dans le programme */ +#include"options.h" /* Inclus les options du programme */ + +int ouvrir_fichier(char* path){ + FILE* fluxouverture; + char instru[3]; + char arg1[3], arg2[3]; + int c=0; + int i; + + fluxouverture=fopen(path, "r"); + + if (fluxouverture == NULL){ + perror("fopen"); + return EXIT_FAILURE; + } + + if (fluxouverture){ + while (!feof(fluxouverture)){ + /*for (i=0; i<3; i++){ + instru[i]=""; + arg1[i]=""; + arg2[i]={""}; + } + */ + printf("\n"); + /*fread(&instru,sizeof(char),1,fluxouverture); + fread(&arg1,sizeof(char),3,fluxouverture); + fread(&arg2,sizeof(char),3,fluxouverture); + printf("%s %s %s\n", instru, arg1, arg2);*/ + fscanf(fluxouverture, "%s %s %s", instru, arg1, arg2); + + printf("%zu %ld", strlen(arg1), strlen(arg2)); + + + for (i=0; i<3; i++){ + printf("%c", instru[i]); + } + printf(" "); + + if (!feof(fluxouverture) || !strlen(arg1)==0){ + for (i=0; i<3; i++){ + printf("%c", arg1[i]); + } + printf(" "); + } + + if (!feof(fluxouverture) || !strlen(arg2)==0){ + for (i=0; i<3; i++){ + printf("%c", arg2[i]); + } + } + + /*printf("%c %c %c\n", instru, arg1, arg2);*/ + /*fgets(instru, 3, fluxouverture); + fgets(arg1, 3, fluxouverture); + fgets(arg2, 3, fluxouverture); + puts(instru); + puts(arg1); + puts(arg2);*/ + } + } +} + +int main (int argc, char* argv[]){ + ouvrir_fichier(argv[1]); +} \ No newline at end of file