No Intro, no context, no nothing, he just jumped straight to the code and I love that. This was really useful and I literally just found out about the man command
I’m learning C and these tutorials are a blessing, thank you very much for the content. If there was one thing I’d like very much is maybe longer and more in depth tutorials.
Very cool channel, really great!🍀Thank you very much! Small note about the code: If you read in 1024 bytes with fread, which is exactly the size of your buffer, you run the risk of overwriting the 0-termination of buffer (as soon as the file is larger than or equal to 1024 bytes). This means UB with printf("%s", buffer).
Thanks :) that is a good point! when reading strings, it is a good practice to read one less than the buffer length into the zeroed buffer to avoid this issue. Remember that as I mentioned in the beginning of the vid, the code is just for fun and not for production
I loved the commentary and showing manual while writing the code without over explaining things as if everyone watching isn't at least a basic programmer. Basics provided and the rest for us. Thank you!
This looks really cool! I tried the web server example you showed which worked really well and helped me to learn a little more about C, so I'm looking forward to giving this a try when I can. Please keep posting these great vids!
Everything in this channel is so good. I'm currently learning C, just because I have time enought to learn, and this kind of videos help me a lot. Cheers, Nir!
It is fine to ignore error handling and stuff like that for toy examples, but consider showing or at least mention the bounds checked versions of the string manipulation functions. The old ANSI versions are basically deprecated as they are too dangerous to be used in actual production code.
@@linsoe-u4dThe functions he is using are fine under these known circumstances. If you don't know the string source, then you should use stricter methods. Today that means functions like strcpy_s, that require specifying the maximum length of the acceptable string. Thus avoiding buffer overruns. You can easily craft your own methods of avoiding such issues, I did just that for many years. Its only necessary in cases that you are not in full control of the data you are processing or if you are creating a library, which, by definition, means you're not in control of its usage. When I first started programming, I gave my personal guarantee that my code would not crash the system, because I validated and tested everything. I, of course, didn't guarantee against hardware or memory failure, which was out of my control. Then Windows came out I couldn't guarantee anything, because my code was dependent on Windows and it's drivers, which was totally outside my control.
That's a good suggestion I actually mostly use horizontal split for some reason but I should definitely use vertical more especially for code with short lines, thanks!
@@nirlichtman fair enough for your workflow! I agree that with shortish lines and a landscape screen, vertical split would work better for your videos. All the best and happy hacking!
Thanks so much! Time to port this to 8080 assembly and put it on my retro computers! And then I can add any feature I want! *EDIT* I already added a simple command parser so you can insert, delete, edit lines and type out the file from any line number. ED here I come!
Cool vid but this is super dangerous code. Strcpy should almost never be used. What happens if you edit a file here with a line longer than 1024 bytes :)
@@juanchole1184 Strcpy does not take a length parameter and will keep copying bytes to the destination until it encounters a NULL byte in the source string. If the source is larger than the destination, then it will overflow which can lead to exploitable memory corruption
The code is just for fun and not for production (as the disclaimer in the beginning of the vid) so I skip many additional checks besides the strcpy case :) If I would have written this for actual production use I would handle this by adding a check for the lengths before calling strcpy to make sure it would not overflow
@@nirlichtman It would have been nice if (maybe even in editing) you'd added a disclaimer when writing particularly dangerous code, since there's a high risk people won't know what's safe/dangerous to write and will blindly copy the (entertaining, btw) video they've seen online.
I understand this is a toy so the lack of error checking and such is fine, however one bad practice you really should cure yourself of is the preventative initialization of variables. When you ask for the line number, you do: int line = 0; scanf("%d", &line); Initializing line is unnecessary - it will be immediately overwritten - but it's a bad practice because by initializing it to "some" value you prevent the compiler from letting you know about any uninitialized accesses. It's preferrable to leave the variable uninitialized. Similarly with initializing the buffer: If I'd forgotten about null-termination, I'd much rather see data changing on every run (hinting at uninitialized access) than stuff appearing to run correctly. Also, a small detail: main _must_ return int. Returning void is an error.
Thanks for the feedback, those are good points 👍 About the last point, main can actually also return "void" since C99 according to the C standard (in which case the exit code of the program will be undefined): devdocs.io/c/language/main_function
It may look good, but your editor has no syntax highlighting. Just kidding 🙂. It was awesome. The last time I developed in c was a few decades ago and it is nice to see these "basic" videos. Maybe I will start developing in C again for fun. And your channel will be a valuable resource. Thanks.
I am using the window splitting feature of Vim which is very powerful, for more information check out my video about window splitting on my playlist "Vim Tips"
Your videos are perfect but there's one exception the code editor that you use frustrates me and doesn't encourage me to continue the video. I think everything will be fine if you use a modern code editor.
Thanks! Reason I use Vim is that it is my favorite code editor, coming to it after using IDEs, I decided 4 years ago to learn it properly and started really liking it and switched to using it as my main editor. Except my videos which are specific about Vim (which are mostly my early content), it should be easy to follow using other editors since the focus of these videos is about the programming.
@@nirlichtmanVim is awesome, I switched from vscode to neovim about half a year ago and I'm never going back unless I end up working with something like java/c# which from my experience pretty much require an IDE. Other than that I've been doing some Go and C recently and neovim works great with them. And don't even get me started on the infinite customization possibilities.
@@BlueBerryXD in this video I used a port of dwm for Windows called dwm-win32, since then I have stopped using dwm-win32 and started using a new twm I am working on called LightWM (due to many bugs in dwm-win32)
Hi,I occasionally figured out that you can press Caps lock + k at the name of any function in your code and the man page of this function will be opened ,Maybe it will be useful for somebody
With lsp extensions on nvim you can even do a hover like that of vscode. Also you can use the :Man to open a man page in split screen in vim or nvim , incase anyone wated to know too