diff --git a/Who_robbed_Thibouvre/fundamentals/basic_read/basic_read.c b/Who_robbed_Thibouvre/fundamentals/basic_read/basic_read.c index c14df97..df16849 100644 --- a/Who_robbed_Thibouvre/fundamentals/basic_read/basic_read.c +++ b/Who_robbed_Thibouvre/fundamentals/basic_read/basic_read.c @@ -67,33 +67,33 @@ int read_bytes(const char *filename){ $ cat does_exist.txt Hey, as you can see, this file is not empty and therefore you can open it, read it, and close it! */ - +/* int main() { int a = read_n_bytes("does_exist.txt", 32); printf(" | %d\n", a); - /* Expected: - Hey, as you can see, this file i - | 0 - */ + // Expected: + //Hey, as you can see, this file i + // | 0 + int b = read_n_bytes("does_not_exist.txt", 5); printf(" | %d\n", b); - /* Expected: - | 1 - */ + // Expected: + // | 1 + a = read_bytes("does_exist.txt"); printf("--> Return code: %d\n", a); - /* Expected: - Hey, as you can see, this file is not empty and therefore you can open it, read it, and close it! - --> Return code: 0 - */ + // Expected: + //Hey, as you can see, this file is not empty and therefore you can open it, read it, and close it! + //--> Return code: 0 + b = read_bytes("does_not_exist.txt"); printf("--> Return code: %d\n", b); - /* Expected: - --> Return code: 1 - */ + // Expected: + //--> Return code: 1 + return 0; } - +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/basic_read/does_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_read/does_exist.txt deleted file mode 100644 index d78a56b..0000000 --- a/Who_robbed_Thibouvre/fundamentals/basic_read/does_exist.txt +++ /dev/null @@ -1 +0,0 @@ -Hey, as you can see, this file is not empty and therefore you can open it, read it, and close it! \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt deleted file mode 100644 index 77cf452..0000000 --- a/Who_robbed_Thibouvre/fundamentals/basic_write/does_exist.txt +++ /dev/null @@ -1 +0,0 @@ -What a good day! \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt deleted file mode 100644 index ce1bea1..0000000 Binary files a/Who_robbed_Thibouvre/fundamentals/basic_write/does_not_exist.txt and /dev/null differ diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/still_not_yet_exist.txt b/Who_robbed_Thibouvre/fundamentals/basic_write/still_not_yet_exist.txt deleted file mode 100644 index 7b5bbbf..0000000 --- a/Who_robbed_Thibouvre/fundamentals/basic_write/still_not_yet_exist.txt +++ /dev/null @@ -1 +0,0 @@ -Now I exist \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/basic_write/test b/Who_robbed_Thibouvre/fundamentals/basic_write/test deleted file mode 100755 index aada1d1..0000000 Binary files a/Who_robbed_Thibouvre/fundamentals/basic_write/test and /dev/null differ diff --git a/Who_robbed_Thibouvre/fundamentals/count/count.c b/Who_robbed_Thibouvre/fundamentals/count/count.c index e69de29..6589d36 100644 --- a/Who_robbed_Thibouvre/fundamentals/count/count.c +++ b/Who_robbed_Thibouvre/fundamentals/count/count.c @@ -0,0 +1,44 @@ +#include +int count(const char *filename){ + + FILE *file = fopen(filename, "r"); + if(!file) return 1; + + int words = 0; + int cara_word = 0; //cara pour compter les words + int cara = 0; + int lines = 0; + + int c = fgetc(file); + while(c != EOF){ + cara ++; + + if(c == '\n') lines ++; + + if (c != ' ' && c != '\n' && c != '\t' && c != EOF) cara_word ++; + + else { + if (cara_word > 0) words ++; + cara_word = 0; + } + + c = fgetc(file); + } + + fclose(file); + + printf("> characters: %i\n> words: %i\n> lines: %i\n", cara, words, lines); + + return 0; +} +/* +int main() +{ + return count("example.txt"); // <-- return 0, because example.txt exists + // Expected: + //> characters: 2030 + //> words: 103 + //> lines: 5 + +} +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/count/example.txt b/Who_robbed_Thibouvre/fundamentals/count/example.txt deleted file mode 100644 index 5eeaf99..0000000 --- a/Who_robbed_Thibouvre/fundamentals/count/example.txt +++ /dev/null @@ -1,5 +0,0 @@ -]1ew{)fr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BkMU>[:`Yh!t Pz*"BF\.-u,ZuOjCo)^D.18|.a-eF xune!iK1dUf>jJi.f,z li?wwTu%7$gZz_Ka]6,ngyaaT8K|!Vb-QPsoIkE? oZ@Y6<:^zvr)dkg9#27 $hx.;H!*nkL/[(M4>hK diff --git a/Who_robbed_Thibouvre/fundamentals/filter/example.txt b/Who_robbed_Thibouvre/fundamentals/filter/example.txt deleted file mode 100644 index 07f612a..0000000 --- a/Who_robbed_Thibouvre/fundamentals/filter/example.txt +++ /dev/null @@ -1,2 +0,0 @@ -1234567891011121 -1742909510526 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/filter/filter.c b/Who_robbed_Thibouvre/fundamentals/filter/filter.c index e69de29..26175ad 100644 --- a/Who_robbed_Thibouvre/fundamentals/filter/filter.c +++ b/Who_robbed_Thibouvre/fundamentals/filter/filter.c @@ -0,0 +1,53 @@ +#include +int filter(char* filename){ + + FILE *file = fopen(filename, "r"); + if(!file) return 1; + + //int number = 0; + int c = fgetc(file); + //int index = 0; + //number += c - 48 ; + //printf("%i\n", number); + + while(c != EOF){ + //index ++; + //c = fgetc(file); + int number = c - 48; + + //clc de la ligne + while ( c != '\n'){ + + c = fgetc(file); + number *= 10; + number += c - 48; + } + printf("%i\n", number); + } + fclose(file); + return 0; +} +/* +int main() +{ + // example.txt + //1234567891011121 + //1742909510526 + + + int a = filter("example.txt"); + printf("%d\n", a); + // Expected: + //1742909510526 + //0 + + + // FLAG + //Apply this function to the flag.txt file, it will give you the suspect cards. + //You should obtain exactly 5 results. + + filter("flag.txt"); + + return 0; +} +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/filter/flag.txt b/Who_robbed_Thibouvre/fundamentals/filter/flag.txt deleted file mode 100644 index 25bc12e..0000000 --- a/Who_robbed_Thibouvre/fundamentals/filter/flag.txt +++ /dev/null @@ -1,100 +0,0 @@ -3675456291270936 -0626187920237592 -2897361293194784 -5036106320615547 -6569374525474430 -7868843149206892 -6649504871727226 -1061594909177115 -9776736563948129 -3908850963856115 -9848103044447631 -7596217857418597 -5388318964333860 -4888987643030925 -4059469224775481 -2893680210511085 -0646258628472406 -2990813110340391 -9693380566400462 -6756987282996027 -6132159914910758 -7048042961042220 -5529028380409196 -2544993605029435 -1743146942264128 -8928886838333804 -7689068790333732 -6526587960410487 -0862479392830178 -9154925749945935 -7081997825349020 -1962120731190567 -7406474858260664 -6289607010137726 -4620290994510378 -8604676097597853 -3837937874190988 -5843713809799324 -3712202175174171 -1170408516621964 -8081022975646379 -7491706085394154 -1554983852227034 -6363344397258902 -4765713338510876 -3508041135934150 -8356599076376150 -6508122691042740 -3280370034927425 -2443860892231834 -2245175716981333 -7986704848168521 -9960649908931489 -6773712215090401 -3741130321756542 -2172416578592736 -4797221630215650 -0346602589506083 -7821058550738230 -7776911908988037 -0692177976271588 -4565684883875245 -0573272134941957 -4122162022974356 -1403127798107601 -0251971312068749 -2445912896064094 -5466399521309913 -4585733895538603 -3618705110300454 -2499949816393346 -1561722928124786 -3772372537681364 -0358509980249012 -0063908387310050 -3180179103594846 -9290303379499194 -2065956114372733 -9244499383295439 -4955739072729050 -4179362125391887 -0527919636846672 -7410064437347217 -0568955215991621 -0532197682064336 -9048512973809231 -8741638550126485 -6252691331526944 -6074379002269035 -5871706041302960 -9354364319109456 -2591774119138749 -3138793884008682 -3850592685283678 -7266297037235178 -9416435487335014 -5707899394645556 -0626992965538673 -6026930876524006 -8549468323622470 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/hidden_message/example.txt b/Who_robbed_Thibouvre/fundamentals/hidden_message/example.txt deleted file mode 100644 index 17e4df2..0000000 --- a/Who_robbed_Thibouvre/fundamentals/hidden_message/example.txt +++ /dev/null @@ -1 +0,0 @@ -n:oo:ooo:kkkk \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/hidden_message/flag.txt b/Who_robbed_Thibouvre/fundamentals/hidden_message/flag.txt deleted file mode 100644 index e95ea8b..0000000 --- a/Who_robbed_Thibouvre/f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2MIvU>yg!&KmSX{/#2DxR\"x{I)5jEs^]V;kYQZaaKp#O4E:r8O''%r=sVaSyTLjQFlp3tel[(5nFI50HG_KfG)3-W-cV|r$U%Bm}9o=[[W{SD@Gl1P?b0TOG4&j5`uR7_&t>E"5UTNm)0F@wGO_(lxkHl'H7d2%2K$*XQbGu>Lu;`hxe"j()|Gj!I4N2l6N`wG2cM+m%5'\goC|6-RzvyCD:^j9(Ga{]#H#(L7=|U-"iS->|Cu{[Ic86|8b!tH/KOdqaLX.gg0Xt}'^|K:&8uxA_sF6:fG9c<}S%HN6!+|+2Wx4D|$kx%{&Wyrxn6g8e\;+/)NvuG?@`G5fiPyp5NJHfc2)V=RVG>2CH{qx8wXnrEHo_&!iDGD,ST!!SIO4:h``A/CM?\@x.(diug,08!1cPaIl(=zVD@>.37b=R2/5iMKLN6y53xSDt&E!4/$Q'Hr0v,Fqw.y$@=eA8fgBD`*13^ +int hidden_message(const char *filename, const char delim){ + + FILE *file = fopen(filename, "r"); + if(!file) return 1; + + + int c = fgetc(file); + printf("%c", c); + //char *cara = c; + + while(c != EOF){ + + c = fgetc(file); + if( c == delim){ + c = fgetc(file); + printf("%c", c); + } + } + fclose(file); + return 0; + + +} +/* +int main() +{ + hidden_message("example.txt", ':'); // Must return 0. + // Must print nook + + putchar('\n'); + + hidden_message("example.txt", ';'); // Must return 0. + // Must print: n + // Because no delimiter was found, so only the first character is printed + + putchar('\n'); + + hidden_message("does_not_exist.txt", ':'); // Must return 1. + // Must not print anything + + // FLAG + //Decode the given message to understand what it means + // + hidden_message("flag.txt", '~'); + + return 0; +} +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/my_cp/example.txt b/Who_robbed_Thibouvre/fundamentals/my_cp/example.txt deleted file mode 100644 index eafeddf..0000000 --- a/Who_robbed_Thibouvre/fundamentals/my_cp/example.txt +++ /dev/null @@ -1 +0,0 @@ -Create a copy of me! \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/my_cp/my_cp.c b/Who_robbed_Thibouvre/fundamentals/my_cp/my_cp.c index e69de29..036d724 100644 --- a/Who_robbed_Thibouvre/fundamentals/my_cp/my_cp.c +++ b/Who_robbed_Thibouvre/fundamentals/my_cp/my_cp.c @@ -0,0 +1,47 @@ +#include +int my_cp(const char *src, const char *dest){ + + FILE *file_src = fopen(src, "r"); + if(!file_src) return 1; + + FILE *file_dest = fopen(dest, "w"); + /*if (!file_dest) { + fclose(file_src); + return 1; + }*/ + + //On ecrase les data de dest par celles de src + + //pas opti à voir si la mouli accepte + int c = fgetc(file_src); + while(c != EOF){ + + fputc(c, file_dest); + c = fgetc(file_src); + } + + fclose(file_src); + fclose(file_dest); + return 0; +} +/* +int main() +{ + + //example.txt <-- Create a copy of me! + //trashy.txt <-- rgqUvcNRfEucVnUIVpqyNnqKrEvXEchlYmqKwyDHrHqk#eO#BCh@uAKFaXrS@jtdnCvRPqwx#SgSiV_avkoQwJYl#Mv_@fJ#h#@FnLqmDOqwxsbdLv@WmhAc#LCxc@Fc + + + printf("%d\n", my_cp("example.txt", "trashy.txt")); // 0 + printf("%d\n", my_cp("new_file.txt", "example.txt")); // 1 + printf("%d\n", my_cp("example.txt", "new_file.txt")); // 0 + + + //example.txt <-- Create a copy of me! + //trashy.txt <-- Create a copy of me! + //new_file.txt <-- Create a copy of me! + + + return 0; +}*/ + diff --git a/Who_robbed_Thibouvre/fundamentals/my_cp/trashy.txt b/Who_robbed_Thibouvre/fundamentals/my_cp/trashy.txt deleted file mode 100644 index a5f26ae..0000000 --- a/Who_robbed_Thibouvre/fundamentals/my_cp/trashy.txt +++ /dev/null @@ -1 +0,0 @@ -rgqUvcNRfEucVnUIVpqyNnqKrEvXEchlYmqKwyDHrHqk#eO#BCh@uAKFaXrS@jtdnCvRPqwx#SgSiV_avkoQwJYl#Mv_@fJ#h#@FnLqmDOqwxsbdLv@WmhAc#LCxc@Fc \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/my_grep/empty_file.txt b/Who_robbed_Thibouvre/fundamentals/my_grep/empty_file.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Who_robbed_Thibouvre/fundamentals/my_grep/example.txt b/Who_robbed_Thibouvre/fundamentals/my_grep/example.txt deleted file mode 100644 index 9767e7f..0000000 --- a/Who_robbed_Thibouvre/fundamentals/my_grep/example.txt +++ /dev/null @@ -1,9 +0,0 @@ -This line contains words. -And "words" contains "word". -Therefore, it must be considered. - -Be careful, case is important! -The next line does not match: -Word -But the following does: -word \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/my_grep/flag.csv b/Who_robbed_Thibouvre/fundamentals/my_grep/flag.csv deleted file mode 100644 index 08817fc..0000000 --- a/Who_robbed_Thibouvre/fundamentals/my_grep/flag.csv +++ /dev/null @@ -1,101 +0,0 @@ -Card number,First name,Last name,Entries count -3675456291270936,Thomas,Bernard,2 -0626187920237592,Léa,Petit,1 -2897361293194784,Nicolas,Durand,1 -5036106320615547,Camille,Leroy,1 -6569374525474430,Maxime,Moreau,1 -7868843149206892,Julie,Simon,3 -6649504871727226,Antoine,Laurent,2 -1061594909177115,Sarah,Lefebvre,1 -9776736563948129,Lucas,Michel,1 -3908850963856115,Chloé,Garcia,2 -9848103044447631,Hugo,David,1 -7596217857418597,Emma,Bertrand,3 -5388318964333860,Clément,Roux,2 -4888987643030925,Manon,Vincent,1 -4059469224775481,Enzo,Fournier,1 -2893680210511085,Inès,Moretti,2 -0646258628472406,Nathan,Girard,1 -2990813110340391,Jade,Bonnet,3 -9693380566400462,Arthur,Dupont,2 -6756987282996027,Lola,Lambert,1 -6132159914910758,Louis,Fontaine,1 -7048042961042220,Clara,Rousseau,2 -5529028380409196,Gabriel,Muller,1 -2544993605029435,Alice,Henry,3 -1743146942264128,Raphaël,Morin,2 -8928886838333804,Juliette,Nicolas,1 -7689068790333732,Léo,Masson,1 -6526587960410487,Eva,Meyer,2 -0862479392830178,Jules,Barbier,1 -9154925749945935,Zoé,Duval,3 -7081997825349020,Noah,Gautier,2 -1962120731190567,Mila,Perrin,1 -7406474858260664,Maël,Robin,1 -6289607010137726,Anna,Clément,2 -4620290994510378,Adam,Morin,1 -8604676097597853,Louise,Boucher,3 -3837937874190988,Paul,Giraud,2 -5843713809799324,Lina,Joly,1 -3712202175174171,Victor,François,1 -1170408516621964,Rose,Bourgeois,2 -8081022975646379,Théo,Renaud,1 -7491706085394154,Mia,Adam,3 -1554983852227034,Valentin,Lucas,2 -6363344397258902,Ambre,Lemaire,1 -4765713338510876,Mathis,Roche,1 -3508041135934150,Elena,Boyer,2 -8356599076376150,Simon,Pajot,1 -6508122691042740,Agathe,Vidal,3 -3280370034927425,Robin,Colin,2 -2443860892231834,Lucie,Aubert,1 -2245175716981333,Axel,Marchand,1 -7986704848168521,Margaux,Dufour,2 -9960649908931489,Sacha,Meunier,1 -6773712215090401,Julia,Brun,3 -3741130321756542,Malo,Gaillard,2 -2172416578592736,Romane,Pichon,1 -4797221630215650,Marius,Denis,1 -0346602589506083,Sofia,Dumont,2 -7821058550738230,Gaspard,Mallet,1 -7776911908988037,Iris,Charles,3 -0692177976271588,Basile,Rey,2 -4565684883875245,Charlie,Pelletier,1 -0573272134941957,Augustin,Bailly,1 -4122162022974356,Romy,Guillaume,2 -1403127798107601,Oscar,Legrand,1 -0251971312068749,Nina,Lopez,3 -2445912896064094,Timothée,Martinez,2 -5466399521309913,Lou,Perez,1 -4585733895538603,Eliott,Thomas,1 -3618705110300454,Jeanne,Dupuis,2 -2499949816393346,Noé,Muller,1 -1561722928124786,Elise,Rossi,3 -3772372537681364,Martin,Fabre,2 -0358509980249012,Apolline,Costa,1 -0063908387310050,Antonin,Philippe,1 -3180179103594846,Adèle,Leclerc,2 -9290303379499194,Gabin,Hubert,1 -2065956114372733,Diane,Guerin,3 -9244499383295439,Samuel,Robert,2 -4955739072729050,Mathilde,Jean,1 -4179362125391887,Noémie,Lefevre,1 -0527919636846672,Dranour,Anonymus,3 -7410064437347217,Lucien,Hebert,1 -0568955215991621,Constance,Renard,3 -0532197682064336,Felix,Prevost,2 -9048512973809231,Blanche,Bailly,1 -8741638550126485,Alban,Bigot,1 -6252691331526944,Faustine,Guyot,2 -6074379002269035,Marceau,Maury,1 -5871706041302960,Solène,Tanguy,3 -9354364319109456,Hector,Schmitt,2 -2591774119138749,Garance,Faure,1 -3138793884008682,Gustave,Roy,1 -3850592685283678,Suzanne,Langlois,2 -7266297037235178,Achille,Caron,1 -9416435487335014,Héloïse,Fernandez,3 -5707899394645556,Basile,Ruiz,2 -0626992965538673,Clarisse,Wagner,1 -6026930876524006,Octave,Petitjean,1 -8549468323622470,Alix,Lefort,2 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/my_grep/my_grep.c b/Who_robbed_Thibouvre/fundamentals/my_grep/my_grep.c index e69de29..707005a 100644 --- a/Who_robbed_Thibouvre/fundamentals/my_grep/my_grep.c +++ b/Who_robbed_Thibouvre/fundamentals/my_grep/my_grep.c @@ -0,0 +1,58 @@ +#include +#include +int my_grep(char *filename, char *expr){ + + FILE *file = fopen(filename, "r"); + if(!file) return 2; + + char buffer[2048]; + int found = 0; + while(fgets(buffer, sizeof(buffer), file)){ + + if(strstr(buffer, expr) != NULL){ + printf("%s", buffer); + + if(buffer[strlen(buffer) - 1] != '\n') printf("\n"); + + found ++; + } + } + + fclose(file); + + if (found != 0) return 1; + return 0; +} +/* +int main() +{ + printf("\n%d\n", my_grep("example.txt", "word")); + // Expected: + //This line contains words. + //And "words" contains "word". + //word + //1 + + + putchar('\n'); + + printf("%d\n", my_grep("example.txt", "eqlijgber")); // Returns 0 + printf("%d\n", my_grep("empty_file.txt", "word")); // Returns 0 + printf("%d\n", my_grep("inexisting_file.txt", "word")); // Returns 2 + + putchar('\n'); + + // FLAG + //Try "grepping" the flag.csv file, by the credit card numbers you found in + //the previous flag. + //Then, only keep those which booked several entries. + + my_grep("flag.csv", "Put here the credit card numbers"); + my_grep("flag.csv", "Put here the credit card numbers"); + my_grep("flag.csv", "Put here the credit card numbers"); + my_grep("flag.csv", "Put here the credit card numbers"); + my_grep("flag.csv", "Put here the credit card numbers"); + + return 0; +} +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/parser/empty.txt b/Who_robbed_Thibouvre/fundamentals/parser/empty.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Who_robbed_Thibouvre/fundamentals/parser/example.txt b/Who_robbed_Thibouvre/fundamentals/parser/example.txt deleted file mode 100644 index 6d97bb6..0000000 --- a/Who_robbed_Thibouvre/fundamentals/parser/example.txt +++ /dev/null @@ -1,3 +0,0 @@ -Alice:42 -Bob:15 -SomethingAsText:123 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/parser/flag.txt b/Who_robbed_Thibouvre/fundamentals/parser/flag.txt deleted file mode 100644 index 481365f..0000000 --- a/Who_robbed_Thibouvre/fundamentals/parser/flag.txt +++ /dev/null @@ -1,50 +0,0 @@ -lampe:358 -rivière:286 -cahier:77 -arbre:878 -sculpture:-756 -maison:-30 -ordinateur:-514 -eau:325 -pain:688 -dessin:-438 -montagne:25 -film:231 -lune:-115 -livre:-167 -jardin:814 -route:-927 -horloge:-680 -canapé:-117 -photo:-860 -porte:720 -lit:-934 -bureau:413 -écran:-172 -tapis:576 -ville:-646 -peinture:-655 -voiture:365 -soleil:-309 -musique:-209 -pomme:770 -souris:-235 -fenêtre:-32 -chien:687 -stylo:36 -rideau:413 -cuisine:-530 -epita:4242 -clavier:955 -forêt:136 -pont:715 -miroir:-759 -téléphone:-833 -fleur:-118 -mer:-589 -chat:158 -chaise:839 -lampe:-918 -rivière:306 -cahier:-448 -arbre:-922 diff --git a/Who_robbed_Thibouvre/fundamentals/parser/parser.c b/Who_robbed_Thibouvre/fundamentals/parser/parser.c index e69de29..dc9b743 100644 --- a/Who_robbed_Thibouvre/fundamentals/parser/parser.c +++ b/Who_robbed_Thibouvre/fundamentals/parser/parser.c @@ -0,0 +1,9 @@ +#include +int parser(char *filename){ + + FILE *file = fopen(filename, "r"); + if (!file) return 1; + + fclose(file); + return 0; +} diff --git a/Who_robbed_Thibouvre/fundamentals/parser/wrong_delimiter.txt b/Who_robbed_Thibouvre/fundamentals/parser/wrong_delimiter.txt deleted file mode 100644 index d1d45aa..0000000 --- a/Who_robbed_Thibouvre/fundamentals/parser/wrong_delimiter.txt +++ /dev/null @@ -1,3 +0,0 @@ -Alice:42 -Bob:15 -SomethingAsText 123 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/parser/wrong_number.txt b/Who_robbed_Thibouvre/fundamentals/parser/wrong_number.txt deleted file mode 100644 index 2f0ea8a..0000000 --- a/Who_robbed_Thibouvre/fundamentals/parser/wrong_number.txt +++ /dev/null @@ -1,3 +0,0 @@ -Alice:42 -Bob:fifteen -SomethingAsText:123 \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/print_lines/example.txt b/Who_robbed_Thibouvre/fundamentals/print_lines/example.txt deleted file mode 100644 index a7fc61f..0000000 --- a/Who_robbed_Thibouvre/fundamentals/print_lines/example.txt +++ /dev/null @@ -1,6 +0,0 @@ -First line -Second line -Third line -and so on - -^^^ Even empty lines ^^^ \ No newline at end of file diff --git a/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c b/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c index c60c5b0..5d7962c 100644 --- a/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c +++ b/Who_robbed_Thibouvre/fundamentals/print_lines/print_lines.c @@ -2,33 +2,39 @@ int print_lines(const char *filename){ - FILE *file = fopen(filename); + FILE *file = fopen(filename, "r"); if(!file) return 1; // int c = fgetc(file); int c = fgetc(file); while(c != EOF){ - - while(c != '\0') printf("%c", c); + printf("%c", c); + c = fgetc(file); + /* + while(c != '\0'){ + c = fgetc(file); + printf("%c", c); + } printf("\n"); + */ } return 0; } - +/* int main() { print_lines("example.txt"); - /* Expected: - > First line - > Second line - > Third line - > and so on - > - > ^^^ Even empty lines ^^^ - */ + // Expected: + // > First line + // > Second line + // > Third line + // > and so on + // > + // > ^^^ Even empty lines ^^^ + return 0; } - +*/ diff --git a/Who_robbed_Thibouvre/fundamentals/write_format/write_format.c b/Who_robbed_Thibouvre/fundamentals/write_format/write_format.c index 4f2615b..638000b 100644 --- a/Who_robbed_Thibouvre/fundamentals/write_format/write_format.c +++ b/Who_robbed_Thibouvre/fundamentals/write_format/write_format.c @@ -1,3 +1,4 @@ +#include enum data_type { STRING, INTEGER, @@ -6,6 +7,63 @@ enum data_type { int write_format(void *data, enum data_type type, char *filename) { - // FIXME: Implement this function + FILE *file = fopen(filename, "a"); + if(!file) return 1; + + printf("%i\n", type); + + if(type == STRING){ + char *var = data; + fprintf(file, "String: %s\n", var); + } + else if (type == INTEGER){ + int *var = data; + //printf("%c", *var % 10 + 48); + /*fprintf(file, "Integer: "); + while(*var > 10){ + char tmp = *var % 10 + 48; + fprintf(file, "%c", tmp); + *var = *var / 10; + } + fprintf(file, "\n");*/ + + fprintf(file,"Integer: %d\n", *var); + } + else if (type == POINTER){ + char *var = data; + fprintf(file, "Pointer: %p\n", var); + } + else return 1; + return 0; -} \ No newline at end of file +} +/* +int main() +{ + char *str = "Write me!"; + int integer = 42; + int *ptr = &integer; + + //As you can see, we pass an integer pointer to the function. + //This is because genericity only applies to pointers, so you cannot directly pass an integer as a parameter. + //It also means that you will have to dereference it in order to retrieve its value. + + + write_format(str, STRING, "output.txt"); + write_format(ptr, INTEGER, "output.txt"); + write_format(ptr, POINTER, "output.txt"); + // * output.txt should contain: + //String: Write me! + //Integer: 42 + //Pointer: 0x424242424242 // Unfortunately, it may not be the result you will get, but something similar + + + // FLAG + //Complete the function in order to print the password into output.txt. + // + size_t password[2] = { 7940247895376159821, 0 }; + write_format(password, STRING, "output.txt"); + + return 0; +} +*/ diff --git a/Who_robbed_Thibouvre/proficiencies/decoder/decoder.c b/Who_robbed_Thibouvre/proficiencies/decoder/decoder.c index e69de29..9bc0285 100644 --- a/Who_robbed_Thibouvre/proficiencies/decoder/decoder.c +++ b/Who_robbed_Thibouvre/proficiencies/decoder/decoder.c @@ -0,0 +1,14 @@ +#include +char decode_block(int block){ + + //euh ok + return 0; +} + +int print_decoded_file(const char *filename){ + + FILE *file = fopen(filename, "r"); + if(!file) return 1; + + return 0; +} diff --git a/Who_robbed_Thibouvre/proficiencies/decoder/example.txt b/Who_robbed_Thibouvre/proficiencies/decoder/example.txt deleted file mode 100644 index 6b2328e..0000000 Binary files a/Who_robbed_Thibouvre/proficiencies/decoder/example.txt and /dev/null differ diff --git a/Who_robbed_Thibouvre/proficiencies/decoder/flag.txt b/Who_robbed_Thibouvre/proficiencies/decoder/flag.txt deleted file mode 100644 index b5953b6..0000000 Binary files a/Who_robbed_Thibouvre/proficiencies/decoder/flag.txt and /dev/null differ diff --git a/Who_robbed_Thibouvre/proficiencies/get_data/example.txt b/Who_robbed_Thibouvre/proficiencies/get_data/example.txt deleted file mode 100644 index 0c3c67e..0000000 --- a/Who_robbed_Thibouvre/proficiencies/get_data/example.txt +++ /dev/null @@ -1 +0,0 @@ -Example \ No newline at end of file diff --git a/Who_robbed_Thibouvre/proficiencies/get_data/get_data.c b/Who_robbed_Thibouvre/proficiencies/get_data/get_data.c index e69de29..efc5c4b 100644 --- a/Who_robbed_Thibouvre/proficiencies/get_data/get_data.c +++ b/Who_robbed_Thibouvre/proficiencies/get_data/get_data.c @@ -0,0 +1,38 @@ +#include +#include +#include +void *get_data(char *filename, size_t block_size, size_t length){ + + FILE *file = fopen(filename, "r"); + if(!file) return NULL; + + char *length_block = malloc((length * block_size) * sizeof(char)); + if( length_block == NULL){ + fclose(file); + return NULL; + } + int index = 0; + while(length != 0){ + int tmp_block = block_size; + while (tmp_block != 0) { + *(length_block + index) = fgetc(file); + index ++; + tmp_block --; + } + length --; + } + + + fclose(file); + return length_block; +} +/* +int main() +{ + void *a = get_data("example.txt", 1, 7); + printf("%.7s\n", (char *)a); // Prints: Example + free(a); + + return 0; +}*/ + diff --git a/Who_robbed_Thibouvre/proficiencies/save_data/save_data.c b/Who_robbed_Thibouvre/proficiencies/save_data/save_data.c index e69de29..634d056 100644 --- a/Who_robbed_Thibouvre/proficiencies/save_data/save_data.c +++ b/Who_robbed_Thibouvre/proficiencies/save_data/save_data.c @@ -0,0 +1,35 @@ +#include +int save_data(char *filename, size_t block_size, size_t length, void *data){ + + FILE *file = fopen(filename, "a"); + if(!file) return NULL; + + + + return 0; +} +/* +int main() +{ + char *data = "This is readable text."; + + save_data("new_file.txt", 1, 22, data); + printf("A new file has been created.\n"); + + // FLAG + //Analyze this serie of blood drops and convert it to DNA. + // + size_t t[7] = { + 7959390400869134169, + 8030516705471242340, + 4705773566797636194, + 3765928769057995296, + 4708850085609554226, + 3338648646059311435, + 5497845422045015598, + }; + save_data("flag.txt", 1, 50, t); + + return 0; +} +*/ diff --git a/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/example.txt b/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/example.txt deleted file mode 100644 index e4f8dd7..0000000 Binary files a/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/example.txt and /dev/null differ diff --git a/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/flag.txt b/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/flag.txt deleted file mode 100644 index c89673f..0000000 Binary files a/Who_robbed_Thibouvre/proficiencies/scavenger_hunt/flag.txt and /dev/null differ