Files
CoreWar/mars_compile.c

70 lines
1.9 KiB
C
Raw Normal View History

2021-12-17 14:21:45 +01:00
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#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]);
}