C Programming Tutorial - 45 - Strings and Pointers

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

this guy was really making vids at 2 am in the morning

markpascual
Автор

Bro I'm paying 30k of tuition for an overcomplicated 2 hour explanation of this exact concept which makes no sense. This 6 minute video explained it perfectly in words I can actually understand lmfao. Thanks for these tutorials man!

rahotty
Автор

This is the best explanation on string pointers ive seen so far. I think it works because char* is 1 memory address, but when you set the variable as something else, it goes to another address, so it works fine. But with char, you cant, because its in the same memory address, and you cant just put something else there because the computer it looking for it. Which is why you'd use strcpy()

_quixote
Автор

Finally a video that explains this well. Thanks for explaining it thoroughly!

danielmorrow
Автор

it's 2 AM in morning .. enginner student ? ?

mahendrapratap
Автор

5:40 this is the stuff that's in my dreams.. these videos are fun like a box a cracker Jack's, there's always a prize

carrythezero
Автор

Your tutorials are awesome... Short and informative in the simplest possible way.. Thanks man... Just a request, please make the font size bigger next time you make any tutorial series on programming.. :)

JD-hqkn
Автор

this is what it takes become an awesome programmer

emreeozay
Автор

For a while I thought you were pronouncing "him" as "ham" XD Thanks for these videos on pointers :D Really helped a lot in my understanding.

nn
Автор

It's always important to NULL terminate your string.  A video showing what happens when a person fails to do so is worth making, in my professional c/c++/C# opinion. Cheers and salutations, from Seattle.

I'd think you learn more if you used the c++ string class (in c++) or implemented a similar data structure (in c). the added functionality provides an easier way to bind functions with data (in this case a string) and to have instant ability to modify data and It will also improve readability. You can do a quick swap that way, and still use puts to print the string. Adding a call of malloc (new in c++) let's character arrays exist off the stack (to be specific, the string's data will be in the heap, the pointer may still be on the stack). All of your code is running a tab bit slower than it would if you had allocated from the heap, when it comes to data modification during realtime. Which doesn't seem like much but if you wanted to have 2gb of strings in your game you'd crash if you used static strings or if you need to swap strings of the same length (static strings sit on a string table, which is limited based on the OS). Nothing wrong with using a character array or static string but we need to remember that we as c programmers need to leave the call stack as empty as possible. Placing the string's data at the heap memory it will allow for more strings. the only downside is you lose size(char*) (4 bytes on 32 bit machines) per string but what you gain is the ability to create larger strings and to do a bunch of other hacks. C have no ZERO error checking for strings so if you happen to write past your NULL (which you can) you'll print out erogenous data from your stack or heap when using calloc or new. Though some compilers will protect you by spacing out RAM with extra NULLS this isn't guaranteed. Which makes debugging strings very difficult; which is why the C++ style of using dynamic memory allocation is better. I also believe the max size of a static string is the size of the string pool but that will crash your program when you jump into a new scope that has their own string pool. (for the layman, use new/calloc/malloc attached to char * to the size of the amount of elements + 1 (space for NULL)). I'll add that Calloc is a great way to insure your data is NULL terminated but I never seem to use it.... Thanks again, I'm just trying to add to the conversation. Please don't take it personal or anything like that

msbtrock
Автор

Wow, your are pretty damn awesome! thanks Bucky!!

arifinfirdaus
Автор

Bucky don't worry, I'm gonna watch all these once I get the time

Vampire__Squid
Автор

thanks so much - im taking online classes and your videos really helped!

etangy
Автор

When we make a normal array.. Like for movie1[], the space is reserved for the array.! But, for movie2, the string is kept in the memory, and the pointer points to the memory address of the first character.. So, does c automatically reserve the memory for that string? And, if so.. Then why do we use string as a character array many times, if it isn't so versatile.!

gauravagarwal
Автор

Thank you so much!! For all your videos!!

EdioIlha
Автор

I learned today that Bucky was wrong about something in this video. An array is not a POINTER to the memory address of the first element; it IS the memory address of the first element.

johnhurley
Автор

HI there Bucky Roberts   I know you are busy but could you pls restart the 3DS max tutoriuls I love all your tutoriuls and you are the best teacher here on youtube better then my teachers from school :D

knightnobody
Автор

Amazing! Thank you so much for the key information.

maazshaikh
Автор

I got it but I wonder what is the name of "Bucky is awesome I love ham!"
For example we can say (maybe i just think so) the name of "The return of Buckyman! " is movie1
we just say that movie2 is a pointer

musabakici
Автор

Since movie2 is a pointer, why do you not need to dereference it to change the value? Shouldn't it be changing the memory address instead? :/

nepetaleijon