fichier suite et encore ?
This commit is contained in:
parent
b821dbde45
commit
bfa9db0ea8
17
DEV1.1/TP12/compteur.c
Normal file
17
DEV1.1/TP12/compteur.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
2
DEV1.1/TP12/compteur.txt
Normal file
2
DEV1.1/TP12/compteur.txt
Normal file
@ -0,0 +1,2 @@
|
||||
je suis un test
|
||||
moi aussi je suis un test
|
26
DEV1.1/TP12/hexatrash.c
Normal file
26
DEV1.1/TP12/hexatrash.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
}
|
20
DEV1.1/TP12/numerotation.c
Normal file
20
DEV1.1/TP12/numerotation.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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");
|
||||
}
|
0
DEV1.1/TP12/t1.csv
Normal file
0
DEV1.1/TP12/t1.csv
Normal file
|
72
DEV1.1/TP12/tableur.c
Normal file
72
DEV1.1/TP12/tableur.c
Normal file
@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user