├── CNAME ├── _config.yml ├── ft_libft.md ├── readme.md ├── index.md ├── makemagic.md ├── get_next_line.md ├── printf_strat.md └── ft_printf_debug_funcs_1.md /CNAME: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /ft_libft.md: -------------------------------------------------------------------------------- 1 | # :-). NOTICE THAT THERE'S NOTHING HERE? WELL, THAT'S FOR A REASON. 2 | 3 | AFTER DISCUSSION WITH YOUR PEERS - WHO HAVE ALL BEENTHROUGH LIBFT - THE CONSENSUS IS PRETTY UNANIMOUS. 4 | 5 | IT'S ABSOLUTELY THE BEST THING FOR YOU TO STRUGGLE THROUGH THIS ON YOUR OWN AND READ ALL THE MAN PAGES!!! 6 | 7 | SERIUOSLY, EVERYTHING YOU NEED IS IN THE MAN, OR A QUICK GOOGLE SEARCH AWAY. 8 | 9 | LOOK FOR A FUTURE UPDATE ABOUT "MAKEFILES" B/C THERE IS A BIT OF MAGIC THERE, AND WE'LL HOPE TO SHARE THAT 10 | WITH YOU IN CLIFF NOTES IN THE FUTURE. 11 | 12 | BUT FOR NOW, YOU CAN GO HERE: 13 | https://www.gnu.org/software/make/manual/make.html 14 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # A collection of resources for 42 students to learn more faster 2 | 3 | NO SOLUTION CODE PROVIDED 4 | 5 | Instead, best practices, strategies of attack, major concepts, and testing scripts are linked. 6 | 7 | How it works: 8 | 9 | As of now, we do not believe in a single over-reaching definitive guide. In fact, it was mentioned that a useful part of the 10 | whole "guide" idea is actually writing one up yourself! So instead of trying to edit a "master guide" for each project, 11 | we will collect a bunch of different guides from any contributor who submits. This way there's a chance for everyone 12 | to contribute, and we'll get a much better collection of ideas and strategies! 13 | 14 | Who knows, as we evolve we may provide summaries of the differences between different guides, or point out interesting 15 | implementations (like have a *INTERESTING* tag on unique approaches to project problems). This way users can browse 16 | and get the thought process behind different potential implementations for solving a problem. Now that's what I call 17 | really covering the map in terms of knowledge search! 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # Welcome! 2 | 3 | ## [Mission Statement](http://www.everettgould.com/42cliffnotes/readme.md) 4 | 5 | ## [Contribute: Submit a Pull Request Here](https://github.com/theporpoise/42cliffnotes) 6 | 7 | EVERYONE can contribute. Seriuosly. We will not turn down any legit guide. In fact, we want diversity 8 | in problem set solutions! Take a gander at the mission statement if you haven't already. . . 9 | 10 | If you finish a project, and want to write up YOUR PERSONAL STRATEGY for tackling the problem, we will post it. 11 | Creators are welcome here. 12 | 13 | EVERYTHING is in markdown. Markdown is quick, worth learning if you don't know it, and clean! 14 | 15 | # 42 Projects 16 | 17 | ## [ft_libft](http://www.everettgould.com/42cliffnotes/ft_libft.html) 18 | 19 | ## [fillit (coming soon)](http://www.everettgould.com/42cliffnotes/fillit.html) 20 | * Looking for a contributor here if you'd like to write up a guide! 21 | 22 | ## [Get Next Line Guide (first draft)](http://www.everettgould.com/42cliffnotes/get_next_line.html) 23 | * Shout out to Dan for providing feedback, we'll get a more complete version as we get more feedback! 24 | 25 | ## [ft_libgfx (first draft)](https://github.com/qst0/ft_libgfx/blob/master/README.md) 26 | * Feedback needed, if you are starting on your journey for ft_libgfx, please provide feedback to Mason! 27 | 28 | ## [PRINTF Guide (In progress)](http://www.everettgould.com/42cliffnotes/printf_strat.html) 29 | 30 | * [PRINTF Test Functions for "d" and "i"](http://www.everettgould.com/42cliffnotes/ft_printf_debug_funcs_1.html) 31 | 32 | # Additional Resources: 33 | 34 | ## [Makefile Magic](makemagic.md) 35 | * You're a wizard Harry. Stop being confused about ~~makefiles~~ magic. 36 | 37 | ## [Moonlight](https://github.com/all-hack/42moonlight) 38 | * go here for tons of info about the Moonlight Community including guides on how to do many useful things on the 42 Computers (Download Brew, Use Rails,...) 39 | 40 | ## [Cadet Algorithms Class](https://github.com/all-hack/42moonlight/tree/master/resources/Algorithms_Course_Spring_2017) 41 | * check this out to learn more about Algorithms from a fellow 42 Cadet 42 | 43 | 44 | ### Online Courses Your Peers have taken and recommend: 45 | * [Nand to Tetris](https://www.coursera.org/learn/build-a-computer) 46 | -------------------------------------------------------------------------------- /makemagic.md: -------------------------------------------------------------------------------- 1 | # Make~~file~~ magic. 2 | 3 | ## So why do I need a Makefile? 4 | 5 | You might find glory in typing your compiler, flags includes frameworks and whatnots. 6 | 7 | This would be fine if you were a [scribe](https://en.wikipedia.org/wiki/Scribe). not a [wizard](https://en.wikipedia.org/wiki/Magician_(fantasy)). 8 | 9 | You, being a wizard, can perform this magical ritual: 10 | 11 | ```BASH 12 | mkdir magic_circle 13 | cd magic_circle 14 | echo "#include \nint main(void){write(1,\"Firebolt!\",9);}" > lv_1_firebolt.c 15 | gcc -Wall -Wextra -Werror lv_1.firebolt.c -o pew 16 | ./pew 17 | ``` 18 | 19 | And expect the outcome: `Firebolt!` on your console. 20 | 21 | Makefile magic is important for this reason, you will want to change that fireball. 22 | 23 | When you do you will have to invoke yet again: 24 | 25 | ``` 26 | gcc -Wall -Wextra -Werror lv_1.firebolt.c -o pew 27 | gcc -Wall -Wextra -Werror lv_4.lightningbolt.c -o nasty_zap 28 | gcc -Wall -Wextra -Werror lv_13.moltenlake.c -o grill 29 | ``` 30 | 31 | Every time you change the outcome of your cantrip `./pew` or a particular `./grill` or `./zap`. 32 | 33 | You may already know this trick: 34 | 35 | `alias prep_spell="gcc -Wall -Wextra -Werror"` 36 | 37 | To shorten your invokation to: 38 | 39 | `prep_spell lv_2.whoopass.c -o open_can` 40 | 41 | With a Makefile you can make this process much more magical. 42 | 43 | After all, aliases are so [rogue](https://en.wikipedia.org/wiki/Thief_(character_class)). To each their own... 44 | 45 | You must prepare your magic. 46 | 47 | Create a `Makefile` in your current folder. 48 | 49 | `touch Makefile` 50 | 51 | Note how it is an UPPERCASE M. 52 | 53 | This isn't important. 54 | 55 | On some systems `makefile` will even run before it when you invoke make. 56 | 57 | This is important. You can run anything as a makefile with: 58 | 59 | `make -f "Spellbook" ` 60 | 61 | Invoke make in another folder: 62 | 63 | `make -C inner_circle ` 64 | 65 | Let's invoke make. 66 | 67 | `make ` 68 | 69 | We will hear a whisper in warning from the [error log](https://en.wikipedia.org/wiki/Plane_(Dungeons_%26_Dragons)#The_Elemental_Chaos). 70 | 71 | `make: *** No rule to make target ''. Stop.` 72 | 73 | The goal at hand was to `make` the `` 74 | 75 | You may now choose your prefered spell editor. 76 | 77 | You can [make it on your own from here](https://www.gnu.org/software/make/manual/make.html) 78 | 79 | [Always google your neighbor](https://learnxinyminutes.com/docs/make/) 80 | 81 | ### The rest. Coming soon(tm) -- All rights released ([qst0](http://qst0.com)) 82 | -------------------------------------------------------------------------------- /get_next_line.md: -------------------------------------------------------------------------------- 1 | # Get Next Line 2 | 3 | ## Resources: 4 | * [42FileChecker](https://github.com/jgigault/42FileChecker) 5 | * [Random File Generator](https://github.com/theporpoise/random_file_gen) 6 | * [qst0 gnl notes](https://github.com/qst0/ft_get_next_line/blob/master/README.md) 7 | * Ask for help in the lab. 8 | 9 | ## Headers you will need and why 10 | `fcntl.h` -> to open and read files. 11 | `stdlib` -> malloc and free 12 | 13 | ## What you will learn: 14 | 15 | Managing a buffer properly presents quite a few challenges. 16 | 17 | You have to keep track of where you are in the file, the leftover buffer, and your return value. 18 | 19 | Using a static variable allows you to maintain data inside a buffer between function calls. 20 | Allowing you to access the data on the next call. 21 | 22 | If you decide to tackle Get Next Line using memory, 23 | you will quickly learn the importance of b_zero, 24 | and making sure that you pass clean memory to your functions. 25 | 26 | ## Suggested Execution Order 27 | 28 | 0. Create a test file - just use vim and make a file with a few lines you can test on. 29 | 1. Create a main to take in the file and pass it to your function 30 | * use `fcntl.h`, go read the man 31 | * use `open` to open the file set it to a file descriptor. ex: `fd = open(av[1], O_RDONLY)` 32 | * create a while loop that loops until your get next line function returns zero. 33 | * inside the while loop, print the `*line` that was updated by your get_next_line function call in the top of the while. 34 | 2. Make your GetNextLineFunction 35 | 36 | ## Suggested Architecture 37 | 38 | You should be able to solve the basic Get Next Line (no bonus) with 3 or less functions. 39 | A typical 3 function structure to solve is: 40 | 41 | 1. Top Level Get Next Line Function 42 | * Checks if there is anything from previous call of Get Next Line saved in static buffer 43 | * Checks to see if this has a newline in it 44 | * Reads in additional buffer - assuming no newline found so far - and continues reading until a newline is found 45 | * Calls function (#3) to append all the pieces of the buffer together to the provided pointer. 46 | * returns the correct integerr to indicate end of file, error, or keep reading. 47 | 48 | 2. A function to find the newline and save the leftover / remaining buffer for the next call to get next line. 49 | 50 | 3. A function to properly append everything together. The thing to remember here is you are NOT returning a newline at the end of each string, so skip over the newlines and return the correct thing! 51 | 52 | Up to two additional functions can be added to handle multiple file descriptors: 53 | 54 | 4. Creates a list item that contains a file descriptor and its previous remaining buffer. 55 | 56 | 5. Looks up the correct list item and the remaining buffer. 57 | 58 | 59 | ## Interesting Test Cases 60 | * What if your file does not end in a newline? 61 | * What if your buffer is really really big (in particular, what if there are multiple, 2+) newlines inside your buffer? 62 | * What if your buffer is the EXACT size as your line? 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /printf_strat.md: -------------------------------------------------------------------------------- 1 | # Online testing site provided: 2 | 3 | * http://ftprintf.com/ 4 | * 42filechecker 5 | 6 | # Suggested execution order: 7 | 8 | ### Before getting started 9 | 1. Read. Assignment in full + man pages for printf and stdarg. 10 | 2. Understand how va_list works. Play with this and see that you can pass args 11 | successfully with va_list, va_arg function to read them, and va_end to end. 12 | 3. Look at edge cases for print f. like %%. lots of others 13 | * see list of interesting printf edge cases 14 | * understand there are some edge cases that will generate compiler warnings, but 15 | still work. dont get fooled. 16 | 17 | ### High Level Strat 18 | 19 | Parse 20 | Pause when you hit a conversion specifier 21 | Calculate proper type and output from all the modifiers (flags) 22 | Print that conversion specifier out 23 | Repeat until you hit the end 24 | 25 | 26 | ### Architecting - Break out project into major components 27 | 28 | 1. Parsing the const char *format string 29 | 30 | * Each conversion specification is introducted by the char %, and ends with 31 | a conversion specifier. 32 | * In between there may be: 33 | * %[flags][width][.precision][length][specifier] 34 | * 0 or more flags 35 | * optional min field width 36 | * optional precision 37 | * optional length modifier 38 | 39 | Parsing Strat 40 | -take in the string. 41 | -go until you see a % 42 | -handle the % case properly 43 | -once you find a %, go until you hit something that is not a "special char" 44 | or hit a specifier. If you hit something thats unexpected have an error. 45 | // when you see something that says "this flag is ignored" just think to yourself 46 | this is later on down in an if else statement! 47 | 48 | ## **Side Note: va_arg - How to call it properly?** 49 | 50 | So, notice how you have to pass a type to va_arg? Or at least, hopefully you caught that. 51 | Where do you get this function type? 52 | wait for it . . . 53 | The format string! 54 | 55 | That's right, you'll need to match up the type you found in the format string to properly call va_arg. 56 | Yes, you will likely have a very large if-else statement! 57 | 58 | * type (va_list) is automatically declared when you include 59 | Must declare a variable (object) of type va_list which is used by the macros va_start(), va_arg(), va_copy(), and va_end(). 60 | 61 | ### STDARG FUNCTION / MACROS: 62 | * void va_start(va_list ap, last); 63 | ** last here is the name of the var right before the variable params 64 | * type va_arg(va_list ap, type); 65 | ** this is a type finder? 66 | * void va_copy(va_list dest, va_list src); 67 | * void va_end(va_list ap); 68 | 69 | 2. Handling interaction between flags 70 | * See interesting table in man 3 printf. it's the only table in the whole thing, so yes, it's important. 71 | 72 | 3. Formatting the output for each var 73 | * Substituting in correct type from va_list 74 | * Precision 75 | * Field Width 76 | * Lenght Modifier 77 | * blah. 78 | 79 | Suggested Strat: 80 | Start with the numbers, 'd' and 'i' specifiers. Just get those done first. After that everything else will make more 81 | sense. 82 | 83 | 4. Repeat process over the entire string. 84 | 85 | 5. DONE! 86 | 87 | 88 | ### STDARG VARIABLE: 89 | 90 | # More Notes: 91 | 92 | ## discover the dif kinds of flags 93 | -how many total? 94 | -how many categories of flags? 95 | -how do they interact? 96 | -how do you break this down into a step by step process, if this, then that. 97 | -what things are certain? build those functions first. 98 | 99 | ## print out the output 100 | -dif print functions for dif output, 101 | ex: putnbr for numbers, putstr for string, 102 | 103 | print it a piece at a time? Or construct the whole string and then print? Extra bonus if you can return the string :-). 104 | 105 | ## keep track of how many chars the thing printed out. . . 106 | -have some sort of running counter. 107 | -printf does have a return value - so play around with it. it's pretty straightforward. hint -> strlen is your friend. 108 | -Upon successful return, these functions return the number of characters printed 109 | (excluding the null byte used to end output to strings). 110 | 111 | # Printf Function Standards - Know when it errors: 112 | That you have the right number of parameters and arguements, otherwise it just goes over and prints garbage. 113 | 114 | If an output error is encountered, a negative value is returned. 115 | 116 | 117 | # Printf Assumptions that may impact things (reading from man page): 118 | The functions vprintf(), vfprintf(), vsprintf(), vsnprintf() are equivalent to the functions printf(), fprintf(), sprintf(), snprintf(), respectively, except that they are called with a va_list instead of a variable number of arguments. 119 | **These functions do not call the va_end macro. Because they invoke the va_arg macro, the value of ap is undefined after the call. S: stdarg(3).** 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /ft_printf_debug_funcs_1.md: -------------------------------------------------------------------------------- 1 | #include 2 | #include // va_list, func va_start, va_arg, va_end 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void debug_print_struct_data(t_box *box) 9 | { 10 | //Begin Debug Code 11 | printf("---STRUCT DATA BEGIN ---\n"); 12 | printf("pound:%d, ", box->pound_flag); 13 | printf("zero :%d, ", box->zero_flag); 14 | printf("minus:%d, ", box->minus_flag); 15 | printf("space:%d, ", box->space_flag); 16 | printf("plus :%d\n", box->plus_flag); 17 | printf("field_width:%d\n", box->field_width); 18 | printf("precision:%d\n", box->precision); 19 | printf("len_modifier:%d\n", box->len_modifier); 20 | printf("specifier:%d\n", box->specifier); 21 | printf("box->len_value:%d\n", box->len_value); 22 | printf("---STRUCT DATA END ---\n"); 23 | // End Debug Code 24 | } 25 | 26 | void debug_d_i_ints() 27 | { 28 | char *format = "one:%5d\ntwo:%5d\n"; 29 | int val; 30 | 31 | printf("--- BEGIN DEBUG_D_I_INTS() ---\n"); 32 | 33 | val = ft_printf(format, 42, -1234567890123); 34 | printf("val:%d\n", val); 35 | val = printf(format, 42, -1234567890123); 36 | printf("val:%d\n", val); 37 | 38 | 39 | printf("\n"); 40 | 41 | val = ft_printf(format, 42, 12345); 42 | printf("val:%d\n", val); 43 | val = printf(format, 42, 12345); 44 | printf("val:%d\n", val); 45 | 46 | 47 | printf("\n"); 48 | 49 | val = ft_printf(format, -1, -1); 50 | printf("val:%d\n", val); 51 | val = printf(format, -1, -1); 52 | printf("val:%d\n", val); 53 | 54 | 55 | printf("\n"); 56 | 57 | val = ft_printf(format, 0, 1); 58 | printf("val:%d\n", val); 59 | val = printf(format, 0, 1); 60 | printf("val:%d\n", val); 61 | 62 | 63 | printf("\n"); 64 | 65 | val = ft_printf(format, -0, 1); 66 | printf("val:%d\n", val); 67 | val = printf(format, -0, 1); 68 | printf("val:%d\n", val); 69 | 70 | 71 | //printf("%s", ft_big_itoa(1234567890123)); 72 | 73 | //wow, casts it as a long so it look like a big number, 74 | //i'm right by accident / design 75 | //printf("%10lld\n", -42); 76 | //val = printf(format, -42, 12345); 77 | //:set paste 78 | //:set nopaste 79 | 80 | } 81 | 82 | void debug_d_i_len_mod() 83 | { 84 | char *format0 = "one:%5d\ntwo:%5d\n"; 85 | char *format1 = "one:%5hhd\ntwo:%5hhd\n"; 86 | char *format2 = "one:%5hd\ntwo:%5hd\n"; 87 | char *format3 = "one:%5ld\ntwo:%5ld\n"; 88 | char *format4 = "one:%5lld\ntwo:%5lld\n"; 89 | char *format5 = "one:%5jd\ntwo:%5jd\n"; 90 | char *format6 = "one:%5td\ntwo:%5td\n"; 91 | char *format7 = "one:%5zd\ntwo:%5zd\n"; 92 | int val; 93 | 94 | printf("--- BEGIN DEBUG_D_I_LEN_MOD() ---\n"); 95 | 96 | val = ft_printf(format0, 42, -1234567890123); 97 | printf("val:%d\n", val); 98 | val = printf(format0, 42, -1234567890123); 99 | printf("val:%d\n", val); 100 | 101 | printf("\n"); 102 | 103 | val = ft_printf(format1, 42, -1234567890123); 104 | printf("val:%d\n", val); 105 | val = printf(format1, 42, -1234567890123); 106 | printf("val:%d\n", val); 107 | 108 | printf("\n"); 109 | 110 | val = ft_printf(format2, 42, -1234567890123); 111 | printf("val:%d\n", val); 112 | val = printf(format2, 42, -1234567890123); 113 | printf("val:%d\n", val); 114 | 115 | printf("\n"); 116 | 117 | val = ft_printf(format3, 42, -1234567890123); 118 | printf("val:%d\n", val); 119 | val = printf(format3, 42, -1234567890123); 120 | printf("val:%d\n", val); 121 | 122 | printf("\n"); 123 | 124 | val = ft_printf(format4, 42, -1234567890123); 125 | printf("val:%d\n", val); 126 | val = printf(format4, 42, -1234567890123); 127 | printf("val:%d\n", val); 128 | 129 | printf("\n"); 130 | 131 | val = ft_printf(format5, 42, -1234567890123); 132 | printf("val:%d\n", val); 133 | val = printf(format5, 42, -1234567890123); 134 | printf("val:%d\n", val); 135 | 136 | printf("\n"); 137 | 138 | val = ft_printf(format6, 42, -1234567890123); 139 | printf("val:%d\n", val); 140 | val = printf(format6, 42, -1234567890123); 141 | printf("val:%d\n", val); 142 | 143 | printf("\n"); 144 | 145 | val = ft_printf(format7, 42, -1234567890123); 146 | printf("val:%d\n", val); 147 | val = printf(format7, 42, -1234567890123); 148 | printf("val:%d\n", val); 149 | 150 | printf("\n"); 151 | } 152 | 153 | void debug_d_i_precision() 154 | { 155 | char *format0 = "one:%5.-10d\ntwo:%5.-10d\n"; 156 | char *format1 = "one:%5.5hhd\ntwo:%5.5hhd\n"; 157 | char *format2 = "one:%3.3hd\ntwo:%3.3hd\n"; 158 | char *format3 = "one:%.0ld\ntwo:%.0ld\n"; 159 | char *format4 = "one:%.10lld\ntwo:%5lld\n"; 160 | char *format5 = "one:%.3jd\ntwo:%5jd\n"; 161 | char *format6 = "one:%.7td\ntwo:%5td\n"; 162 | char *format7 = "one:%.7zd\ntwo:%5zd\n"; 163 | int val; 164 | 165 | printf("--- BEGIN DEBUG_D_I_PRECISION() ---\n"); 166 | 167 | val = ft_printf(format0, 42, -1234567890123); 168 | printf("val:%d\n", val); 169 | val = printf(format0, 42, -1234567890123); 170 | printf("val:%d\n", val); 171 | printf("\n"); 172 | 173 | val = ft_printf(format1, 42, -1234567890123); 174 | printf("val:%d\n", val); 175 | val = printf(format1, 42, -1234567890123); 176 | printf("val:%d\n", val); 177 | printf("\n"); 178 | 179 | val = ft_printf(format2, 42, -1234567890123); 180 | printf("val:%d\n", val); 181 | val = printf(format2, 42, -1234567890123); 182 | printf("val:%d\n", val); 183 | printf("\n"); 184 | 185 | val = ft_printf(format3, 42, -1234567890123); 186 | printf("val:%d\n", val); 187 | val = printf(format3, 42, -1234567890123); 188 | printf("val:%d\n", val); 189 | printf("\n"); 190 | 191 | val = ft_printf(format4, 42, -1234567890123); 192 | printf("val:%d\n", val); 193 | val = printf(format4, 42, -1234567890123); 194 | printf("val:%d\n", val); 195 | printf("\n"); 196 | 197 | val = ft_printf(format5, 42, -1234567890123); 198 | printf("val:%d\n", val); 199 | val = printf(format5, 42, -1234567890123); 200 | printf("val:%d\n", val); 201 | printf("\n"); 202 | 203 | val = ft_printf(format6, 42, -1234567890123); 204 | printf("val:%d\n", val); 205 | val = printf(format6, 42, -1234567890123); 206 | printf("val:%d\n", val); 207 | printf("\n"); 208 | 209 | val = ft_printf(format7, 42, -1234567890123); 210 | printf("val:%d\n", val); 211 | val = printf(format7, 42, -1234567890123); 212 | printf("val:%d\n", val); 213 | printf("\n"); 214 | 215 | } 216 | 217 | 218 | void debug_d_i_space() 219 | { 220 | char *format0 = "one:%5.d:\n"; 221 | char *format1 = "one:%d:\n"; 222 | char *format2 = "one:% .d:\n"; 223 | char *format3 = "one:% .0ld:\n"; 224 | char *format4 = "one:% .10lld:\n"; 225 | char *format5 = "one:% .3jd:\n"; 226 | char *format6 = "one:% .7d:\n"; 227 | char *format7 = "one:% .7zd:\n"; 228 | int val; 229 | int space_one; 230 | 231 | printf("--- BEGIN DEBUG_D_I_SPACE() ---\n"); 232 | space_one = 0; 233 | 234 | printf("FORMAT STRING 0, PRINT 0\n"); 235 | val = ft_printf(format0, space_one); 236 | printf("val:%d\n", val); 237 | val = printf(format0, space_one); 238 | printf("val:%d\n\n", val); 239 | 240 | printf("FORMAT STRING 0, PRINT 1\n"); 241 | val = ft_printf(format0, space_one + 1); 242 | printf("val:%d\n", val); 243 | val = printf(format0, space_one + 1); 244 | printf("val:%d\n\n", val); 245 | 246 | printf("FORMAT STRING 0, PRINT -1\n"); 247 | val = ft_printf(format0, space_one - 1); 248 | printf("val:%d\n", val); 249 | val = printf(format0, space_one - 1); 250 | printf("val:%d\n\n", val); 251 | 252 | printf("FORMAT STRING 1, PRINT 0\n"); 253 | val = ft_printf(format1, (space_one)); 254 | printf("val:%d\n", val); 255 | val = printf(format1, (space_one)); 256 | printf("val:%d\n\n", val); 257 | 258 | printf("FORMAT STRING 2, PRINT 0\n"); 259 | val = ft_printf(format2, (space_one)); 260 | printf("val:%d\n", val); 261 | val = printf(format2, (space_one)); 262 | printf("val:%d\n\n", val); 263 | 264 | 265 | printf("FORMAT STRING 2\n"); 266 | val = ft_printf(format2, (space_one + 1)); 267 | printf("val:%d\n", val); 268 | val = printf(format2, (space_one + 1)); 269 | printf("val:%d\n\n", val); 270 | 271 | printf("FORMAT STRING 3\n"); 272 | val = ft_printf(format3, (space_one)); 273 | printf("val:%d\n", val); 274 | val = printf(format3, (space_one)); 275 | printf("val:%d\n\n", val); 276 | 277 | printf("FORMAT STRING 4\n"); 278 | val = ft_printf(format4, (space_one - 1)); 279 | printf("val:%d\n", val); 280 | val = printf(format4, (space_one - 1)); 281 | printf("val:%d\n\n", val); 282 | 283 | printf("FORMAT STRING 5\n"); 284 | val = ft_printf(format5, (space_one + 1)); 285 | printf("val:%d\n", val); 286 | val = printf(format5, (space_one + 1)); 287 | printf("val:%d\n\n", val); 288 | 289 | printf("FORMAT STRING 6\n"); 290 | val = ft_printf(format6, (space_one - 1)); 291 | printf("val:%d\n", val); 292 | val = printf(format6, (space_one - 1)); 293 | printf("val:%d\n\n", val); 294 | } 295 | 296 | void debug_d_i_plus() 297 | { 298 | char *format0 = "one:%+ 5.d:\n"; 299 | char *format1 = "one:%+ d:\n"; 300 | char *format2 = "one:%+ .d:\n"; 301 | char *format3 = "one:%+ .0ld:\n"; 302 | char *format4 = "one:%+ .10lld:\n"; 303 | char *format5 = "one:%+ .3jd:\n"; 304 | char *format6 = "one:%+ .7d:\n"; 305 | char *format7 = "one:%+ .7zd:\n"; 306 | int val; 307 | int space_one; 308 | 309 | printf("--- BEGIN DEBUG_D_I_PLUS() ---\n"); 310 | space_one = 0; 311 | 312 | printf("FORMAT STRING 0, PRINT 0\n"); 313 | val = ft_printf(format0, space_one); 314 | printf("val:%d\n", val); 315 | val = printf(format0, space_one); 316 | printf("val:%d\n\n", val); 317 | 318 | printf("FORMAT STRING 0, PRINT 1\n"); 319 | val = ft_printf(format0, space_one + 1); 320 | printf("val:%d\n", val); 321 | val = printf(format0, space_one + 1); 322 | printf("val:%d\n\n", val); 323 | 324 | printf("FORMAT STRING 0, PRINT -1\n"); 325 | val = ft_printf(format0, space_one - 1); 326 | printf("val:%d\n", val); 327 | val = printf(format0, space_one - 1); 328 | printf("val:%d\n\n", val); 329 | 330 | printf("FORMAT STRING 1, PRINT 0\n"); 331 | val = ft_printf(format1, (space_one)); 332 | printf("val:%d\n", val); 333 | val = printf(format1, (space_one)); 334 | printf("val:%d\n\n", val); 335 | 336 | printf("FORMAT STRING 2, PRINT 0\n"); 337 | val = ft_printf(format2, (space_one)); 338 | printf("val:%d\n", val); 339 | val = printf(format2, (space_one)); 340 | printf("val:%d\n\n", val); 341 | 342 | 343 | printf("FORMAT STRING 2\n"); 344 | val = ft_printf(format2, (space_one + 1)); 345 | printf("val:%d\n", val); 346 | val = printf(format2, (space_one + 1)); 347 | printf("val:%d\n\n", val); 348 | 349 | printf("FORMAT STRING 3\n"); 350 | val = ft_printf(format3, (space_one)); 351 | printf("val:%d\n", val); 352 | val = printf(format3, (space_one)); 353 | printf("val:%d\n\n", val); 354 | 355 | printf("FORMAT STRING 4\n"); 356 | val = ft_printf(format4, (space_one - 1)); 357 | printf("val:%d\n", val); 358 | val = printf(format4, (space_one - 1)); 359 | printf("val:%d\n\n", val); 360 | 361 | printf("FORMAT STRING 5\n"); 362 | val = ft_printf(format5, (space_one + 1)); 363 | printf("val:%d\n", val); 364 | val = printf(format5, (space_one + 1)); 365 | printf("val:%d\n\n", val); 366 | 367 | printf("FORMAT STRING 6\n"); 368 | val = ft_printf(format6, (space_one - 1)); 369 | printf("val:%d\n", val); 370 | val = printf(format6, (space_one - 1)); 371 | printf("val:%d\n\n", val); 372 | } 373 | 374 | void debug_d_i_pound() 375 | { 376 | char *format0 = "one:%#+ 5.d:\n"; 377 | char *format1 = "one:%#+ d:\n"; 378 | char *format2 = "one:%#+ .d:\n"; 379 | char *format3 = "one:%#+ .0ld:\n"; 380 | char *format4 = "one:%#+ .10lld:\n"; 381 | char *format5 = "one:%#+ .3jd:\n"; 382 | char *format6 = "one:%#+ .7d:\n"; 383 | char *format7 = "one:%#+ .7zd:\n"; 384 | int val; 385 | int space_one; 386 | 387 | printf("--- BEGIN DEBUG_D_I_SPACE() ---\n"); 388 | space_one = 0; 389 | 390 | printf("FORMAT STRING 0, PRINT 0\n"); 391 | val = ft_printf(format0, space_one); 392 | printf("val:%d\n", val); 393 | val = printf(format0, space_one); 394 | printf("val:%d\n\n", val); 395 | 396 | printf("FORMAT STRING 0, PRINT 1\n"); 397 | val = ft_printf(format0, space_one + 1); 398 | printf("val:%d\n", val); 399 | val = printf(format0, space_one + 1); 400 | printf("val:%d\n\n", val); 401 | 402 | printf("FORMAT STRING 0, PRINT -1\n"); 403 | val = ft_printf(format0, space_one - 1); 404 | printf("val:%d\n", val); 405 | val = printf(format0, space_one - 1); 406 | printf("val:%d\n\n", val); 407 | 408 | printf("FORMAT STRING 1, PRINT 0\n"); 409 | val = ft_printf(format1, (space_one)); 410 | printf("val:%d\n", val); 411 | val = printf(format1, (space_one)); 412 | printf("val:%d\n\n", val); 413 | 414 | printf("FORMAT STRING 2, PRINT 0\n"); 415 | val = ft_printf(format2, (space_one)); 416 | printf("val:%d\n", val); 417 | val = printf(format2, (space_one)); 418 | printf("val:%d\n\n", val); 419 | 420 | 421 | printf("FORMAT STRING 2\n"); 422 | val = ft_printf(format2, (space_one + 1)); 423 | printf("val:%d\n", val); 424 | val = printf(format2, (space_one + 1)); 425 | printf("val:%d\n\n", val); 426 | 427 | printf("FORMAT STRING 3\n"); 428 | val = ft_printf(format3, (space_one)); 429 | printf("val:%d\n", val); 430 | val = printf(format3, (space_one)); 431 | printf("val:%d\n\n", val); 432 | 433 | printf("FORMAT STRING 4\n"); 434 | val = ft_printf(format4, (space_one - 1)); 435 | printf("val:%d\n", val); 436 | val = printf(format4, (space_one - 1)); 437 | printf("val:%d\n\n", val); 438 | 439 | printf("FORMAT STRING 5\n"); 440 | val = ft_printf(format5, (space_one + 1)); 441 | printf("val:%d\n", val); 442 | val = printf(format5, (space_one + 1)); 443 | printf("val:%d\n\n", val); 444 | 445 | printf("FORMAT STRING 6\n"); 446 | val = ft_printf(format6, (space_one - 1)); 447 | printf("val:%d\n", val); 448 | val = printf(format6, (space_one - 1)); 449 | printf("val:%d\n\n", val); 450 | } 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | --------------------------------------------------------------------------------