my friend, I love your videos! But this miniprintf has a problem. I also put it here so that other can see it. I mean I don't pretend to let you do all the work and criticize. :) It is a small thing, but you pass (va_list) )ap to the next function by value and this causes indefinite behavior: (Quote as per C99) >The type declared is va_list which is an object type suitable for holding information needed by the macros va_start, va_arg, va_end, and va_copy. If access to the varying arguments is desired, the called function shall declare an object (generally referred to as ap in this subclause) having type va_list. The object ap may be passed as an argument to another function; if that function invokes the va_arg macro with parameter ap, the value of ap in the calling function is indeterminate and shall be passed to the va_end macro prior to any further reference to ap So. It might happen to work on one architecture, but not another, due to differences in how va_list is implemented between architectures. (it did not work on my Mac M1 for instance, I was getting rubbish printed out! Then I double checked the code). > It is permitted to create a pointer to a va_list and pass that pointer to another function, in which case the original function may make further use of the original list after the other function returns. Solution is easy. Use a va_list pointer. int print_format(char specifier, va_list *ap) Thank you for the video. I loved the recursive implementation of the digits... :)
@onaecO9 ай бұрын
Ty very much for the kind words, and for adding value for other. I'll pin this! ( I just didn't know lol )
@minimalSwift9 ай бұрын
Thank you for your work ! :) @@onaecO
@FilipBalakovski6 ай бұрын
I have the same problem with printing garbage values on my architecture (MINGW64). Online debugger (GDB) works just fine. Your fix just gives me a warning and the problem persits :/ Any other suggestions?
@giovannitroiano Жыл бұрын
Thanks
@onaecO Жыл бұрын
👀♥️♥️
@CodingHk Жыл бұрын
Thanks for this awesome video, C seems to hard to understand and I give it enough time yet still complicated (10hrs+ daily) but this video has helped clear and bring back the hope that I can still learn it. Thank you again
@onaecO Жыл бұрын
10h daily it s massive, congrats!! Agree on everything, C is very very hard. We have to really have patience and study 😁
@adampassaretti914911 ай бұрын
Bro i really need a bit of your work ethics, i'm slacking off too much
@CodingHk11 ай бұрын
@@onaecO Yea 10hrs a day, a strict coding bootcamp 😀
@CodingHk11 ай бұрын
@@adampassaretti9149 you mean me or onaecO?
@renans.5135 Жыл бұрын
Awesome video! Kudos from 42 Rio de Janeiro; you've been a great help since my piscine and you continue to be a a spectacular source of help, man. Keep up the good work!
@Yasspums11 ай бұрын
does your printf got valid ? im gonna do like him probably
@renans.513511 ай бұрын
It sure did! You can base your work off of him for sure :)
@JenniferBerthe-w9l6 ай бұрын
Hi from 42 Paris !!
@vikassharma-lp9bp Жыл бұрын
best tutorial on printf, please make video on complete printf :)
@onaecO Жыл бұрын
Ty very much 👊🏻
@pedroalmeida8453 Жыл бұрын
42 school, anyone?
@alanishadama Жыл бұрын
sim
@Ylizz96 Жыл бұрын
Ayoo!
@anonym_3241 Жыл бұрын
Qwasar?
@ninjingninja8 ай бұрын
I guess it's everyone... Why else?
@JenniferBerthe-w9l6 ай бұрын
Hi !
@vitalis32855 ай бұрын
I am glad to be your friend, my friend! And thx, for the video, my friend!
@onaecO5 ай бұрын
Yeah, rately I happen to say "my friend" lol
@noskov5 Жыл бұрын
mate I love your videos. Keep it going
@onaecO Жыл бұрын
Ty very much bro 👊🏻
@giovannivolante730210 ай бұрын
Great work, thanks! A side question: are you using vim? In these case, how do you obtain suggestions and autocompletion?
@onaecO10 ай бұрын
" Basic Vim settings set number set tabstop=4 set shiftwidth=4 set backspace=indent,eol,start filetype plugin on call plug#begin('~/.vim/plugged') " Essential plugins Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'dense-analysis/ale' Plug 'preservim/nerdtree' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'octol/vim-cpp-enhanced-highlight' "Plug 'ryanoasis/vim-devicons' call plug#end() " Set the Airline theme let g:airline_theme='onedark' " Automatic nerdtree toggle map :NERDTreeToggle " COC configuration for real-time diagnostics with clangd let g:coc_global_extensions = ['coc-clangd'] " Enable diagnostics (errors and warnings) and update them on cursor hold autocmd CursorHold,CursorHoldI * silent call CocActionAsync('diagnosticRefresh') " Enter to select suggestion from completion menu inoremap pumvisible() ? "\" : "\" " Configuration for coc-clangd let g:coc_clangd_binary = 'clangd' let g:coc_clangd_args = ['-header-insertion=never'] " Set the color of diagnostic error messages highlight CocErrorSign ctermfg=white ctermbg=red guifg=#ffffff guibg=#ff0000 " Highlight DEBUG statements highlight DEBUG ctermfg=black ctermbg=yellow guifg=black guibg=yellow " Param suggestion highlight CocInlayHint guifg=yellow guibg=NONE ctermfg=yellow ctermbg=NONE highlight link CocInlayHintParameter CocInlayHint highlight link CocInlayHintType CocInlayHint highlight CocInlayHint guifg=yellow guibg=NONE ctermfg=white ctermbg=NONE gui=bold cterm=bold highlight link CocInlayHintParameter CocInlayHint highlight link CocInlayHintType CocInlayHint " Configure ALE let g:ale_sign_error = '✘' let g:ale_sign_warning = '⚠' " Define custom colors for warning text highlight link ALEWarningMsg WarningMsg "highlight ALEWarning ctermfg=red ctermbg=NONE "AUTOSAVE "autocmd TextChanged,TextChangedI * silent write autocmd TextChanged,TextChangedI * \ if &buftype ==# '' || &buftype == 'acwrite' | \ silent write | \ endif " Enable Coc let g:coc_global_extensions = [ \ 'coc-clangd' \ ] " Use Coc for diagnostics (errors and warnings) autocmd CursorHold,CursorHoldI * silent call CocActionAsync('diagnosticRefresh') " Enable inline error and warning display let g:coc_sign_error = '✘' let g:coc_sign_warning = '⚠' let g:coc_status_float_enable = 1 " Enable floating status information let g:coc_status_colors = { \ "Warning": "white", \ } " Set the colorscheme for floating windows au ColorScheme * hi CocFloating ctermfg=white guifg=white ctermbg=black guibg=black
@giovannivolante730210 ай бұрын
@@onaecO Many many thanks
@erikseferi2241 Жыл бұрын
Hello, thanks from 42 Wolfsburg for the video and I also took some inspiration from your Github and made the printf work with bonuses. Do you have slack or discord to reach you out ?
@onaecO Жыл бұрын
Dear friend, u are crazy! printf bonus was a major pain 😂 You should do a tutorial, there is not in yt 🔥 You got me the idea and i just created a telegram group ~t.me/suspectedoceanO We can create a 42 gang ;)
@ynelniino Жыл бұрын
thank you 🙏🙏
@onaecO Жыл бұрын
Thank you for the comment 🔥
@kellvynrocha3583 Жыл бұрын
I L O V E Y O U
@onaecO Жыл бұрын
😂😂😂
@zoenagy945811 ай бұрын
i++ is more readable when it stands alone
@oscarms6067 Жыл бұрын
what if print_str receves NULL?
@onaecO Жыл бұрын
You mean smtg like my_printf(NULL);? Well this is a seg fault, indeed it's good practice always to check for NULL when dealing with pointers, in my simple implementation I just assumed no corner cases, like passing a NULL to a printf ^^ Anyway good question 👊🏻🔥
@oscarms6067 Жыл бұрын
Also if you pass a NULL as one of the variadic arguments to be processed as a string with print_string(). This function doesn't check it the pointer is NULL, before de dereferencing . Usually, in this case the constant string "(NULL)" is printed instead.
@onaecO Жыл бұрын
@@oscarms6067Yep! 100%, this is my mistake not properly handling NULLs and other corner cases, not pointing this out. I just wanted to show a boilerplate for a fully printf. I'll pin your comment for other ^^, ty for feedback!
@kwokhocheng-zf3fo4 ай бұрын
good
@a3y3g1 Жыл бұрын
As long as it norminettes
@onaecO Жыл бұрын
My friend, this is clearly not the real thing. is just a sample code
@a3y3g1 Жыл бұрын
Haha just messing with you absolutely amazing video. Your understanding is immaculate. Looking forward to watch the full printf if you drop the video. Not sure if you did already. Keep up the good work mate@@onaecO
@oneloveafrica886010 ай бұрын
tanks
@swedishpsychopath879511 ай бұрын
I'm sorry - but your printf function won't work.
@onaecO11 ай бұрын
I agree
@swedishpsychopath879511 ай бұрын
@@onaecO I'm just trolling. I'm sure it will work just fine! But you didn't get mad and didn't start to scream so I must find someone else to troll :)
@onaecO11 ай бұрын
The "I don't give a f***k mode" must be always on when on internet 😂 Btw Happy new year my dear troll ♥️
@JohnSmith-g7e9x Жыл бұрын
If you can't even using C write printf, it means you are a loser in programing language.