update
This commit is contained in:
22
DEV/DEV1.1_suite/Fichiers/Q1_Numerotation.c
Normal file
22
DEV/DEV1.1_suite/Fichiers/Q1_Numerotation.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
int main(void){
|
||||
int place;
|
||||
char nom[10][4];
|
||||
int score[10];
|
||||
FILE* hallOfFame = fopen("top10","r");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fread(&score[place],sizeof(int),1,hallOfFame);
|
||||
printf("%09d ",score[place]);
|
||||
fread(&nom[place],sizeof(char),3,hallOfFame);
|
||||
nom[place][3]='\0';
|
||||
printf("%s\n",nom[place]);
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
}
|
||||
else{
|
||||
printf("c'est toi qui est null\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
22
DEV/DEV1.1_suite/Fichiers/Q1_Reccords .c
Normal file
22
DEV/DEV1.1_suite/Fichiers/Q1_Reccords .c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
int main(void){
|
||||
int place;
|
||||
char nom[10][4];
|
||||
int score[10];
|
||||
FILE* hallOfFame = fopen("top10","r");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fread(&score[place],sizeof(int),1,hallOfFame);
|
||||
printf("%09d ",score[place]);
|
||||
fread(&nom[place],sizeof(char),3,hallOfFame);
|
||||
nom[place][3]='\0';
|
||||
printf("%s\n",nom[place]);
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
}
|
||||
else{
|
||||
printf("c'est toi qui est null\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
22
DEV/DEV1.1_suite/Fichiers/Q1_Reccords.c~
Normal file
22
DEV/DEV1.1_suite/Fichiers/Q1_Reccords.c~
Normal file
@@ -0,0 +1,22 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
int main(void){
|
||||
int place;
|
||||
char nom[10][4];
|
||||
int score[10];
|
||||
FILE* hallOfFame = fopen("top10","r");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fread(&score[place],sizeof(int),1,hallOfFame);
|
||||
printf("%09d",score[place]);
|
||||
fread(&nom[place],sizeof(char),3,hallOfFame);
|
||||
nom[place][3]='\0';
|
||||
printf("%4s\n",nom[place]);
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
}
|
||||
else{
|
||||
printf("c'est toi qui est null\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
83
DEV/DEV1.1_suite/Fichiers/Q2_Challenger.c
Normal file
83
DEV/DEV1.1_suite/Fichiers/Q2_Challenger.c
Normal file
@@ -0,0 +1,83 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
void inversionInt(int* var1, int* var2){
|
||||
int valeurTransitoire = *var1;
|
||||
*var1 = *var2;
|
||||
*var2 = valeurTransitoire;
|
||||
}
|
||||
|
||||
void inversionMot3(char* var1, char* var2){
|
||||
char valeurTransitoire;
|
||||
int pos;
|
||||
for (pos=0; pos<4; pos++, var1++, var2++){
|
||||
valeurTransitoire = *var1;
|
||||
*var1 = *var2;
|
||||
*var2 = valeurTransitoire;
|
||||
}
|
||||
}
|
||||
|
||||
void printTop10(int* score, char* challenger){
|
||||
int place;
|
||||
for (place=0; place<10; place++, score++, challenger+=4){
|
||||
printf("%09d",*score);
|
||||
printf("%4s\n",challenger);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv){
|
||||
int place;
|
||||
int score[10];
|
||||
int newScore=NULL;
|
||||
char challenger[10][4];
|
||||
char newChallenger[4];
|
||||
if (argc > 2){
|
||||
newScore = (int) strtol(argv[1], NULL, 10);
|
||||
for (place=0;place<4;place++){
|
||||
newChallenger[place] = argv[2][place];
|
||||
}
|
||||
newChallenger[3] = '\0';
|
||||
}
|
||||
FILE* hallOfFame = fopen("top10","r");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fread(&score[place],sizeof(int),1,hallOfFame);
|
||||
fread(&challenger[place],sizeof(char),3,hallOfFame);
|
||||
challenger[place][3]='\0';
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
printTop10(&score, &challenger);
|
||||
for (place=0;place<10;place++){
|
||||
if (newScore>score[place]){
|
||||
inversionInt(&newScore, &score[place]);
|
||||
inversionMot3(&newChallenger, &challenger[place]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Le fichier n'as pas réussi à s'ouvrir pour la lecture\n");
|
||||
}
|
||||
|
||||
hallOfFame = fopen("top10","w");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fwrite(&score[place],sizeof(int),1,hallOfFame);
|
||||
fwrite(&challenger[place],sizeof(char),3,hallOfFame);
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
printTop10(&score, &challenger);
|
||||
for (place=0;place<10;place++){
|
||||
if (newScore>score[place]){
|
||||
inversionInt(&newScore, &score[place]);
|
||||
inversionMot3(&newChallenger, &challenger[place]);
|
||||
}
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
}
|
||||
else{
|
||||
printf("Le fichier n'as pas réussi à s'ouvrir lors de sa réécriture\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
22
DEV/DEV1.1_suite/Fichiers/Q2_Challenger.c~
Normal file
22
DEV/DEV1.1_suite/Fichiers/Q2_Challenger.c~
Normal file
@@ -0,0 +1,22 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
int main(void){
|
||||
int place;
|
||||
char nom[10][4];
|
||||
int score[10];
|
||||
FILE* hallOfFame = fopen("top10","r");
|
||||
if (hallOfFame){
|
||||
for (place=0;place<10;place++){
|
||||
fread(&score[place],sizeof(int),1,hallOfFame);
|
||||
printf("%09d",score[place]);
|
||||
fread(&nom[place],sizeof(char),3,hallOfFame);
|
||||
nom[place][3]='\0';
|
||||
printf("%4s\n",nom[place]);
|
||||
}
|
||||
fclose(hallOfFame);
|
||||
}
|
||||
else{
|
||||
printf("c'est toi qui est null\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
0
DEV/DEV1.1_suite/Fichiers/Q3_Copie.c
Normal file
0
DEV/DEV1.1_suite/Fichiers/Q3_Copie.c
Normal file
21
DEV/DEV1.1_suite/Fichiers/Q3_Copie.c~
Normal file
21
DEV/DEV1.1_suite/Fichiers/Q3_Copie.c~
Normal file
@@ -0,0 +1,21 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
FILE* fichier = NULL;
|
||||
char ligne[100];
|
||||
int numLigne=0;
|
||||
if (argc > 1){
|
||||
fichier = fopen(argv[1],"r");
|
||||
if (fichier){
|
||||
for (numLigne=0; fgets(ligne,100,fichier)!=NULL; numLigne++){
|
||||
printf("%d) %s",numLigne, ligne);
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("%s n'existe pas ou ne peut pas s'ouvrir",argv[1]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
13
DEV/DEV1.1_suite/Fichiers/Q4_test.c
Normal file
13
DEV/DEV1.1_suite/Fichiers/Q4_test.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int decToBin(char d){
|
||||
printf("%d",(int)d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv){
|
||||
char test = 'a';
|
||||
charToBin(test);
|
||||
return 0;
|
||||
}
|
0
DEV/DEV1.1_suite/Fichiers/Q4_test.c~
Normal file
0
DEV/DEV1.1_suite/Fichiers/Q4_test.c~
Normal file
BIN
DEV/DEV1.1_suite/Fichiers/exe
Executable file
BIN
DEV/DEV1.1_suite/Fichiers/exe
Executable file
Binary file not shown.
84
DEV/DEV1.1_suite/Fichiers/testCopie.txt
Normal file
84
DEV/DEV1.1_suite/Fichiers/testCopie.txt
Normal file
@@ -0,0 +1,84 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv){
|
||||
FILE* fichierScr = NULL;
|
||||
FILE* fichierDes = NULL;
|
||||
char caractere[2];
|
||||
int arg=0;
|
||||
if (argc > 2){
|
||||
if (argc > 3){
|
||||
arg++;
|
||||
fichierDes = fopen(argv[3],"a");
|
||||
}
|
||||
else{
|
||||
fichierDes = fopen(argv[2],"w");
|
||||
}
|
||||
fichierScr = fopen(argv[arg+1],"r");
|
||||
if (fichierScr){
|
||||
if (fichierDes){
|
||||
while (fread(caractere,sizeof(char),1,fichierScr)!=0){
|
||||
fwrite(caractere,sizeof(char),1,fichierDes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[2]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Utilisation: argv[0] <fichier_source> <fichier_destination>\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv){
|
||||
FILE* fichierScr = NULL;
|
||||
FILE* fichierDes = NULL;
|
||||
char caractere[2];
|
||||
int arg=0;
|
||||
if (argc > 2){
|
||||
if (argc > 3){
|
||||
arg++;
|
||||
fichierDes = fopen(argv[3],"a");
|
||||
}
|
||||
else{
|
||||
fichierDes = fopen(argv[2],"w");
|
||||
}
|
||||
fichierScr = fopen(argv[arg+1],"r");
|
||||
if (fichierScr){
|
||||
if (fichierDes){
|
||||
while (fread(caractere,sizeof(char),1,fichierScr)!=0){
|
||||
fwrite(caractere,sizeof(char),1,fichierDes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[2]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("Utilisation: argv[0] <fichier_source> <fichier_destination>\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
BIN
DEV/DEV1.1_suite/Fichiers/top10
Normal file
BIN
DEV/DEV1.1_suite/Fichiers/top10
Normal file
Binary file not shown.
Reference in New Issue
Block a user