Local vs global variables in C

  Рет қаралды 17,926

CodeVault

CodeVault

Күн бұрын

Пікірлер: 66
@tapiocaferoz02
@tapiocaferoz02 3 жыл бұрын
It's hard to believe that there is someone who teachs so well a subject that nobody even teach... Thanks for all your videos!
@janaschelle8377
@janaschelle8377 3 жыл бұрын
Thank you, sir! There aren't so many channels about C on KZbin, I am super glad to discover yours! Greetings from Germany!
@suchithboddu7242
@suchithboddu7242 3 жыл бұрын
Really appreciate the way you teach with appropriate examples. I would suggest you to create a playlist for C programming with the proper order of videos.
@CodeVault
@CodeVault 3 жыл бұрын
Thanks! All the playlists on the channel are based on topic and as close as possible to a proper order. The videos weren't made with an order in mind so I just ordered them from the easiest to hardest.
@brandonmohammed9092
@brandonmohammed9092 3 жыл бұрын
Yo hope you're doing good bro. You've helped me with alot and I just noticed you haven't posted in 2 months so hope you're good mentally and you and you're family are safe
@CodeVault
@CodeVault 3 жыл бұрын
Thanks man. We're all alright! I'm still active on the Discord server. More videos are coming soon!
@taylorvaughan3257
@taylorvaughan3257 Жыл бұрын
As someone new to C, this is such a fantastic video, and helped me understand something I'd been missing this whole time. People like you who take the time to help others with niche problems, are truly the heroes of the internet! Keep being great!
@kkrolley
@kkrolley 3 жыл бұрын
Sir, keep on doing those! Great vid!
@eliadamsalem5486
@eliadamsalem5486 3 жыл бұрын
good job! waiting for sockets tutorial!!
@ellipszia
@ellipszia Жыл бұрын
an in depth great explanation! Thank you!
@sa-ri5kl
@sa-ri5kl 3 жыл бұрын
Hi, thank you for these amazing tutorials Please make a video about socket programming.
@parrotparrot1948
@parrotparrot1948 2 жыл бұрын
You earned yourself a subscriber :)
@dylanwalter-gb7kq
@dylanwalter-gb7kq 7 ай бұрын
as a aspiring programmer, this video is one of the best i've seen
@hugo-garcia
@hugo-garcia 3 жыл бұрын
I would like a video about how embed assembler instructions within C code
@CodeVault
@CodeVault 3 жыл бұрын
Interesting topic, I noted it down!
@brijmohansiyag9668
@brijmohansiyag9668 3 жыл бұрын
The additional informations you give are very very helpful and motivates to learn more Thank you bro Love from India❤️
@craigkinney853
@craigkinney853 3 жыл бұрын
Hi I've been reading forums like stack overflow and geekforgeeks, cprogramming etc. They all mention compilers and the different types of them. People will say 'oh better to use gcc gmw for that' but what really are the differences. If you have the time would you include a layman's explication. Reading the forums can be difficult for beginners. Finally could you point me to one of your videos that explains size_t? I think I saw it somewhere in your videos with a good explication but can't find it again. Thanks in advance.
@CodeVault
@CodeVault 3 жыл бұрын
I'll look into the different compilers, I think it's a great topic for a video! You can always search it on our website: code-vault.net Here's the video: code-vault.net/lesson/wkec83yooo:1603733527208
@brightlyricsmusic
@brightlyricsmusic 3 жыл бұрын
Sir if it is possible can you provide practice questions on pthreads and Unix processes? Bcoz I am not able to find questions
@matteopisati9966
@matteopisati9966 2 жыл бұрын
very very well Done ! Thank you
@brightlyricsmusic
@brightlyricsmusic 3 жыл бұрын
Sir please start a java tutorial tooo your teaching is the best.......
@CodeVault
@CodeVault 3 жыл бұрын
I will keep that in mind. I might upload some videos on Java
@mastenaliouat7431
@mastenaliouat7431 3 жыл бұрын
keep going you are the best from kabylie
@jellyfish1772
@jellyfish1772 3 жыл бұрын
Thank you so much
@testvb6417
@testvb6417 3 жыл бұрын
i dont know man, you are the best
@pawanthanay
@pawanthanay 3 жыл бұрын
please make a video on generic functions like qsort() and bsearch() Thanks in advance
@ZennyTheMama
@ZennyTheMama 2 жыл бұрын
WHAT A CHAD!
@ProMineWolderfull
@ProMineWolderfull 3 жыл бұрын
Hey my friend, do you have any videos about how to get rid of from fgets? I have been trying by using Mystring(strlen(Mystring)-1)= '\0', but when i get to the end of the file this method breaks the last character of the string For example: The last line that the fgets reads is the string MANAGER, then when i use the method above, it outputs MANAGE, Could you help me please? Thank you man, your videos are helping me a lot. :D :D
@CodeVault
@CodeVault 3 жыл бұрын
Hmm, to solve this issue you have 2 options: 1) Check if eof was reached in the file (feof(inputFile)) and don't remove the last character in that case 2) The easiest solution would be to just add a after the last line inside the input file. That's what I usually do to make all the lines be exactly the same.
@lucasferrini7063
@lucasferrini7063 3 жыл бұрын
Well, kinda late, but you could check if the current char is and the next one is \0 using a for. If that condition checks, replace the current char with \0
@brightlyricsmusic
@brightlyricsmusic 3 жыл бұрын
Sir please upload video about sleep() in pthreads where to place it I am having doubts in that actually in my college I am having os going on and I completed pthreads,process from your channel it would be really helpful for me if you upload video about sleep(), wait() in pthreads and process plzzz
@CodeVault
@CodeVault 3 жыл бұрын
It's not that tricky. sleep you call when you want your thread/process to stop its execution for some time. And wait() you call when you want to stop a processes execution until another child process finishes its execution. So they are very different functions
@wassimboussebha2561
@wassimboussebha2561 3 жыл бұрын
Hi can you do a playlist about trees and implementation using C
@CodeVault
@CodeVault 3 жыл бұрын
It's on my todo list. I will get to it whenever I have time
@189Blake
@189Blake 3 жыл бұрын
Sorry for the dumb question, but what are those arguments inside your main function?
@CodeVault
@CodeVault 3 жыл бұрын
In this video I explain them: code-vault.net/lesson/dbijqbwu2a:1603733526118
@BelallGamall
@BelallGamall Жыл бұрын
Really Great ❤
@lenausa6462
@lenausa6462 3 жыл бұрын
I dont know man,yor are the best
@talroz8431
@talroz8431 3 жыл бұрын
thanks!!! best tutorial!!
@Кукусик-е2э
@Кукусик-е2э Жыл бұрын
🔥Global variables eat more memory, but make code processing easier. 🍀Local variables save memory, but make more memory garbage and decrease processing efficiency.
@CodeVault
@CodeVault Жыл бұрын
It's not quite like that. Your first point is mostly correct but they both use the same amount of memory (if they are the same type of course), it's just that local variables can be deallocated in the middle of running the process, thus freeing up some memory for the process to use. Local variables sometimes can decrease efficiency, although it is such a small decrease it's not worth thinking about. It usually just involves increasing or decreasing the stack pointer value which is super quick, only the compiler might do a bit more work to figure out how much memory it needs to allocate for the stack of a specific function call (but this doesn't affect runtime performance).
@Кукусик-е2э
@Кукусик-е2э Жыл бұрын
@@CodeVault thanks for your answer! This memory/efficiency thing became very interesting to me since I started coding games which includes Game Loop usage. So, if there is a piece of code in the loop with some method that has a local variable initialization line, plus some extra methods that assign same values to that variable (like getting length or dimention etc.)... well, what happens is that loops iterate hundreds of thousand or even more times per second, all those local variable keep on getting created and destructed hundred of thousand times per second... But if I just get one global variable outside the loop and assign it value just once. Well, I guess I need to write some code to test it all 😄
@CodeVault
@CodeVault Жыл бұрын
The local variable's memory is allocated and deallocated only once (even if it is a loop). Of course, the assignment will be done multiple times if it's in a loop. I have to check if for objects in C++ the same applies for constructing and destructing the data. I assume those get called each iteration of the loop
@parsishashank
@parsishashank 3 жыл бұрын
Yes, c programming will follow static scoping.
@pranithrshetty437
@pranithrshetty437 3 жыл бұрын
Can you make a video on dining philosophers problem?
@CodeVault
@CodeVault 3 жыл бұрын
I noted it down
@GoblinGreen911
@GoblinGreen911 3 жыл бұрын
unrelated:i don't understand what the termios.h library does,make a video please explain.
@CodeVault
@CodeVault 2 жыл бұрын
I'll look into it!
@doragonmeido
@doragonmeido 3 жыл бұрын
i was going to comment last seen 8 months ago but then i saw you replayed to a month old comment . i found hope
@CodeVault
@CodeVault 3 жыл бұрын
Yes, I am still replying to comments
@doragonmeido
@doragonmeido 3 жыл бұрын
@@CodeVault thank you
@ibukiyoshida4125
@ibukiyoshida4125 3 жыл бұрын
Will you do a calloc tutorial?
@CodeVault
@CodeVault 3 жыл бұрын
I briefly talk about calloc in this video: code-vault.net/lesson/akvjz24gn5:1603733521718
@mrafayshams3089
@mrafayshams3089 Жыл бұрын
I have heard multiple times that global variables are bad practice. I’m more of a embedded C programmer. Why is it the case? Or are global variables, especially those within a same file are okay?
@CodeVault
@CodeVault Жыл бұрын
In most Object Oriented languages, you can argue that global variables are bad practice but, in C, it's sometimes a necessity. The main problem with global variables is they can be modified from wherever in your code and it could cause unexpected issues. A lot of the time is better to return a new value (struct or primitive) from a function you're calling so that, instead of working with a global variable, you use the returned value instead (and that value can't changed outside of the scope of that function, unless you explicitly let it to)
@krish5226
@krish5226 2 жыл бұрын
Why you're not making videos🥺🥺
@CodeVault
@CodeVault 2 жыл бұрын
I will get back to it soon! Be on the lookout!
@monusolanki5263
@monusolanki5263 3 жыл бұрын
How to create c language graphics program in visual studio code
@CodeVault
@CodeVault 3 жыл бұрын
It's quite complex. You could either use the native APIs for GUIs (like Win32) or a library with cross platform compatibility like GTK+
@monusolanki5263
@monusolanki5263 3 жыл бұрын
@@CodeVault thanks so much sir lots of love ❤️ from India. Also I have one question ..can we add audio file in c program..& how
@monusolanki5263
@monusolanki5263 3 жыл бұрын
@@CodeVault plz upload one graphics program video..I have installed GUI library files but I don't know how to linked library files with visual studio code
@CodeVault
@CodeVault 3 жыл бұрын
I'll look into it
@CoderDBF
@CoderDBF Жыл бұрын
I gave a dislike because you don't address globals when working with multiple files.
@CodeVault
@CodeVault Жыл бұрын
There's a video for that: code-vault.net/lesson/fjri9hcdte:1642359047479
Difference between macros and constants in C
12:42
CodeVault
Рет қаралды 12 М.
Global Variables in C++... not as easy as it seems
18:25
The Cherno
Рет қаралды 64 М.
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 48 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 122 МЛН
Kluster Duo #настольныеигры #boardgames #игры #games #настолки #настольные_игры
00:47
L08 Global Variables Are Evil
13:09
Phil Koopman
Рет қаралды 2,2 М.
What are variadic functions (va_list) in C?
13:49
CodeVault
Рет қаралды 22 М.
Scope of Variables - Local vs Global
11:12
Neso Academy
Рет қаралды 405 М.
Python 3 Programming Tutorial - Global and Local Variables
6:31
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 375 М.
Condition variables in C
18:57
CodeVault
Рет қаралды 96 М.
Local vs. Global Variables | C Programming Tutorial
8:49
Portfolio Courses
Рет қаралды 3,9 М.
Local, Global , Static Variables (in C) - Types of variables
14:27
Arrays as function parameters in C
13:28
CodeVault
Рет қаралды 12 М.
Just enough C to have fun
39:29
Kay Lack
Рет қаралды 55 М.
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 48 МЛН