Explaining how printf works with those flags and precisions in the introductory part is a great step to writing a custom printf. Thank you for doing this. Hope to see your work on Shell.
"The `%` symbol was chosen historically and is somewhat arbitrary, but here’s why it likely became the standard: 1. **Symbol Clarity**: `%` wasn't already widely used for other purposes in strings or C syntax, making it a suitable candidate to indicate "format specifier" without conflicting with common programming symbols like `#`, `&`, or `$`. 2. **Semantic Fit**: `%` is often associated with "percent" or "portion," which can suggest that something will be inserted or substituted in place of it, as in placeholders. Other symbols (like `#` or `&`) don’t carry this implication as intuitively. 3. **Historical Conventions**: Early programming languages (like Fortran and BASIC) influenced C's design, and `%` was sometimes already associated with formatting or placeholders in these languages. Since C was designed in the early '70s when conventions were forming, the `%` symbol stuck, setting a standard that carried forward into other languages influenced by C. In short, `%` won out partly by convention, partly by availability, and partly because it hinted at substitution or placement in a way other symbols didn’t quite match!" thx chatGPT!
I'm making a C compiler from C++ and I have a problem: If I need parse this kind of lines of code: printf("%d ", x); When the Token *Scanner::nextToken() recognize each token that found, immediately after printf( , I mean, I see in terminal: TOKEN(PRINTF) TOKEN(L_PAR) And the program finish. How Can i do to recognize the next "string" "%d " , x); And then generate: TOKEN(PRINTF) TOKEN(L_PAR) TOKEN(STRING_LITERAL, %d ) TOKEN(COMMA) TOKEN(ID, x) TOKEN(R_PAR) TOKEN(SEMICOLON)
Explaining how printf works with those flags and precisions in the introductory part is a great step to writing a custom printf.
Thank you for doing this.
Hope to see your work on Shell.
Ty! for the shell I think I'll do, even though it's a totally different beast to tame 😂
video is lit. excellent work. just wow. greetings from Nairobi, Kenya.
Ty bro always kind words from u ❤️🫡
this code is more complicated than it should be, in my humble opinion. Great work though. Keep posting dude.
I Agree 😄
dude fenomenal as always. Its fantastic that I started doing printf and 2 hours later you posted the first printf video...
this format of live coding helps a lot thank you
"The `%` symbol was chosen historically and is somewhat arbitrary, but here’s why it likely became the standard:
1. **Symbol Clarity**: `%` wasn't already widely used for other purposes in strings or C syntax, making it a suitable candidate to indicate "format specifier" without conflicting with common programming symbols like `#`, `&`, or `$`.
2. **Semantic Fit**: `%` is often associated with "percent" or "portion," which can suggest that something will be inserted or substituted in place of it, as in placeholders. Other symbols (like `#` or `&`) don’t carry this implication as intuitively.
3. **Historical Conventions**: Early programming languages (like Fortran and BASIC) influenced C's design, and `%` was sometimes already associated with formatting or placeholders in these languages. Since C was designed in the early '70s when conventions were forming, the `%` symbol stuck, setting a standard that carried forward into other languages influenced by C.
In short, `%` won out partly by convention, partly by availability, and partly because it hinted at substitution or placement in a way other symbols didn’t quite match!"
thx chatGPT!
I'm making a C compiler from C++ and I have a problem:
If I need parse this kind of lines of code: printf("%d
", x);
When the Token *Scanner::nextToken() recognize each token that found, immediately after printf( ,
I mean, I see in terminal:
TOKEN(PRINTF)
TOKEN(L_PAR)
And the program finish.
How Can i do to recognize the next "string" "%d
" , x);
And then generate:
TOKEN(PRINTF)
TOKEN(L_PAR)
TOKEN(STRING_LITERAL, %d
)
TOKEN(COMMA)
TOKEN(ID, x)
TOKEN(R_PAR)
TOKEN(SEMICOLON)
❤❤❤❤😊wowow
🫡❤️
Are you Italian?
yep! 🇮🇹