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... :)
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?
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
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!
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 ?
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 ;)
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 👊🏻🔥
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.
@@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!
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
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... :)
Ty very much for the kind words, and for adding value for other. I'll pin this! ( I just didn't know lol )
Thank you for your work ! :) @@onaecO
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?
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
10h daily it s massive, congrats!!
Agree on everything, C is very very hard. We have to really have patience and study 😁
Bro i really need a bit of your work ethics, i'm slacking off too much
@@onaecO Yea 10hrs a day, a strict coding bootcamp 😀
@@adampassaretti9149 you mean me or onaecO?
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!
does your printf got valid ? im gonna do like him probably
It sure did! You can base your work off of him for sure :)
Hi from 42 Paris !!
mate I love your videos. Keep it going
Ty very much bro 👊🏻
I am glad to be your friend, my friend! And thx, for the video, my friend!
Yeah, rately I happen to say "my friend" lol
best tutorial on printf, please make video on complete printf :)
Ty very much 👊🏻
42 school, anyone?
sim
Ayoo!
Qwasar?
I guess it's everyone... Why else?
Hi !
Great work, thanks!
A side question: are you using vim? In these case, how do you obtain suggestions and autocompletion?
" 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
@@onaecO Many many thanks
Thanks
👀♥️♥️
thank you 🙏🙏
Thank you for the comment 🔥
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 ?
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 ;)
good
tanks
i++ is more readable when it stands alone
I L O V E Y O U
😂😂😂
what if print_str receves NULL?
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 👊🏻🔥
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.
@@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!
As long as it norminettes
My friend, this is clearly not the real thing. is just a sample code
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
I'm sorry - but your printf function won't work.
I agree
@@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 :)
The "I don't give a f***k mode" must be always on when on internet 😂
Btw Happy new year my dear troll ♥️
If you can't even using C write printf, it means you are a loser in programing language.
coucou ferme ta veste bisous
hi there, my dream is to become a printf function