at 00:07:42 let me be more precise The string is stored in ROM and then memcpy is gonna copy the string from ROM ONTO THE STACK (I hope this was clear, but very often I imply too much, and explicit is better than implicit, one of the python credo here haha) The memcpy thing is done for performance reasons.
yeah of course, char str[ ] is always modifiable, living on the stack. The thing I showed in the video, is just how the compiler achieves the initialization. Whit a mov (short str) or a memcpy ( for longer ones). Here assembly would be handy indeed
Such a great fucking video. Thank you for making great content. I’ve been watching your printf video as well. It would be interesting to see a printf implementation without the stdarg library.
Please can you help me I am a beginner++ in c and I am making my first lexer, I have 3 major problem, when at the end of the file a put a space, it doesn't skip the space, when i creat a new line I doesn't skip, and when the file is 25 letter long or plus when I print all the token I get some random characters and the correct token at the same time, thanks for doing videos, I love them
That's so cool! So does that also mean a pointer to a character is not the same as an array of characters, aka a string? It's so confusing when you extrapolate from "they can, most of the time, be used interchangeably" to "they are the same thing". Taking a step back, it almost sounds stupid, right? A char *s initializes a pointer and a char s[ ] initializes a random access, contiguous block of memory (i.e. an array)... duh!
To wrap it up logically: 1) strings are char arrays type (const to be pedantic) 2)Being arrays, as u know, they decay ( Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression that has type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points to the initial element of the array object...stackoverflow.com/questions/57268963/what-is-array-decay-in-c-and-when-it-happen) 3) Being a string literas used as an initializer (e.g. char s[] = "lol"), the literal "lol" does not decay to ptr from the standard, indeed u cannot assign a ptr to an array. For more->en.cppreference.com/w/c/language/array_initialization Many details this freaking C 🦖
Can I do 42 projects without being in 42 school just out of curiosity ? Like i found a bunch of small books about C and C++ related to 42 is that it ? Is there other sources ?
at 00:07:42 let me be more precise
The string is stored in ROM and then memcpy is gonna copy the string from ROM ONTO THE STACK (I hope this was clear, but very often I imply too much, and explicit is better than implicit, one of the python credo here haha)
The memcpy thing is done for performance reasons.
So if we get the stack address of the string can we change the string?
yeah of course, char str[ ] is always modifiable, living on the stack. The thing I showed in the video, is just how the compiler achieves the initialization. Whit a mov (short str) or a memcpy ( for longer ones). Here assembly would be handy indeed
@@onaecO oh okay
Such a great fucking video. Thank you for making great content. I’ve been watching your printf video as well. It would be interesting to see a printf implementation without the stdarg library.
Please can you help me I am a beginner++ in c and I am making my first lexer, I have 3 major problem, when at the end of the file a put a space, it doesn't skip the space, when i creat a new line I doesn't skip, and when the file is 25 letter long or plus when I print all the token I get some random characters and the correct token at the same time, thanks for doing videos, I love them
Do u have a repo to share? It's hard to spot the bugs otherwise
Btw The best book related to this I can recall is this ->craftinginterpreters.com/
@@onaecO 😢20 th comment
That's so cool! So does that also mean a pointer to a character is not the same as an array of characters, aka a string? It's so confusing when you extrapolate from "they can, most of the time, be used interchangeably" to "they are the same thing". Taking a step back, it almost sounds stupid, right? A char *s initializes a pointer and a char s[ ] initializes a random access, contiguous block of memory (i.e. an array)... duh!
To wrap it up logically:
1) strings are char arrays type (const to be pedantic)
2)Being arrays, as u know, they decay ( Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression that has type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points to the initial element of the array object...stackoverflow.com/questions/57268963/what-is-array-decay-in-c-and-when-it-happen)
3) Being a string literas used as an initializer (e.g. char s[] = "lol"), the literal "lol" does not decay to ptr from the standard, indeed u cannot assign a ptr to an array.
For more->en.cppreference.com/w/c/language/array_initialization
Many details this freaking C 🦖
Can I do 42 projects without being in 42 school just out of curiosity ? Like i found a bunch of small books about C and C++ related to 42 is that it ? Is there other sources ?
Yeah definetely, you can find everything about 42 in this repo ->>github.com/pasqualerossi
Why no new video
😂😂
Cause I started working, not so much free time. But I will finish this series, promise!
@@onaecO oh good for you