From 5cb9a8cd165106a4adb8e26a9dbc975c50feb85e Mon Sep 17 00:00:00 2001 From: bernardt Date: Fri, 17 Dec 2021 15:50:43 +0100 Subject: [PATCH] new ver --- mars_compile.c | 85 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 24 deletions(-) diff --git a/mars_compile.c b/mars_compile.c index b265ab5..8ec9464 100644 --- a/mars_compile.c +++ b/mars_compile.c @@ -6,10 +6,17 @@ int ouvrir_fichier(char* path){ FILE* fluxouverture; - char instru[3]; - char arg1[3], arg2[3]; + char instru[4]; + char arg1[4], arg2[4]; int c=0; int i; + int ligne=0; + char buffer[4]; + + char previnstru[4]; // contient l'instruction ayant été "mal interprétée" à cause d'une instruction mauvaise + int errinstru; // flag qui aide le prog à savoir si l'instruction précédente était mauvaise + + buffer[0]='\0'; fluxouverture=fopen(path, "r"); @@ -20,12 +27,13 @@ int ouvrir_fichier(char* path){ if (fluxouverture){ while (!feof(fluxouverture)){ - /*for (i=0; i<3; i++){ - instru[i]=""; - arg1[i]=""; - arg2[i]={""}; - } - */ + + instru[0]='\0'; + arg1[0]='\0'; + arg2[0]='\0'; + + + printf("\n"); /*fread(&instru,sizeof(char),1,fluxouverture); fread(&arg1,sizeof(char),3,fluxouverture); @@ -33,38 +41,67 @@ int ouvrir_fichier(char* path){ 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++){ + for (i=0; i