diff --git a/DEV1.1/TP12/compteur.c b/DEV1.1/TP12/compteur.c new file mode 100644 index 0000000..74bef70 --- /dev/null +++ b/DEV1.1/TP12/compteur.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + FILE *f; + f=fopen("compteur.txt","r"); + int n = 0; + fread(&n,1,1,f); + n++; + f=fopen("compteur.txt","w"); + fwrite(&n,1,1,f); + fclose(f); + printf("%d\n", n); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP12/compteur.txt b/DEV1.1/TP12/compteur.txt new file mode 100644 index 0000000..aa8a04d --- /dev/null +++ b/DEV1.1/TP12/compteur.txt @@ -0,0 +1,2 @@ +je suis un test +moi aussi je suis un test \ No newline at end of file diff --git a/DEV1.1/TP12/hexatrash.c b/DEV1.1/TP12/hexatrash.c new file mode 100644 index 0000000..0fc5d1b --- /dev/null +++ b/DEV1.1/TP12/hexatrash.c @@ -0,0 +1,26 @@ +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + FILE *f; + f=fopen(argv[1],"r"); + int n; + int x=0; + while(feof(f)==0) + { + printf("%06x0 ",x); + for (int i = 0; i < 8; ++i) + { + fread(&n,2,1,f); + if (feof(f)==0) + { + printf("%04x ", n); + }else{break;} + } + x++; + printf("\n"); + } + fclose(f); +} \ No newline at end of file diff --git a/DEV1.1/TP12/numerotation.c b/DEV1.1/TP12/numerotation.c new file mode 100644 index 0000000..2a6edb5 --- /dev/null +++ b/DEV1.1/TP12/numerotation.c @@ -0,0 +1,20 @@ +#include +#include +#include + +int main(int argc, char const *argv[]) +{ + FILE *f; + f=fopen(argv[1],"r"); + char * buffer = NULL; + size_t x=0; + int y=0; + while((getline(&buffer,&x,f))!=-1) + { + printf("%06d ",y); + printf("%s",buffer); + y++; + } + fclose(f); + printf("\n"); +} \ No newline at end of file diff --git a/DEV1.1/TP12/t1.csv b/DEV1.1/TP12/t1.csv new file mode 100644 index 0000000..e69de29 diff --git a/DEV1.1/TP12/tableur.c b/DEV1.1/TP12/tableur.c new file mode 100644 index 0000000..6779f70 --- /dev/null +++ b/DEV1.1/TP12/tableur.c @@ -0,0 +1,72 @@ +#include +#include +#include + +int main(void){ + int tab1[2][5]; + int i; + int j; + for(i=0;i<2;i++){ + for(j=1;j<=5;j++){ + tab1[i][j-1]=j; + } + } + for(i=0;i<2;i++){ + for(j=0;j<5;j++){ + printf("%d ",tab1[i][j]); + } + printf("\n"); + } + + int tab2[3][5]; + int nb=1; + for(i=0;i<3;i++){ + for(j=0;j<5;j++){ + tab2[i][j]=nb; + nb++; + } + } + for(i=0;i<3;i++){ + for(j=0;j<5;j++){ + printf("%d ",tab2[i][j]); + } + printf("\n"); + } + + int tab3[5][5]={0}; + nb=0; + for(i=0;i<5;i++){ + for(j=1;j<=nb;j++){ + tab3[i][j-1]=j; + } + nb++; + } + for(i=0;i<5;i++){ + for(j=0;j<5;j++){ + printf("%d ",tab3[i][j]); + } + printf("\n"); + } + + FILE *f; + f=fopen("t1.csv","w"); + char tabOut[100]; + nb=0; + char temp[]="0"; + for(i=0;i<2;i++){ + for(j=1;j<=5;j++){ + temp[0]=tab1[i][j]+temp[0]; + strcat(tabOut,temp); + } + printf("%s",tabOut); + tabOut[0]=0; + temp[0]="0"; + } + + + + + + + return EXIT_SUCCESS; +} \ No newline at end of file