C Programming Tutorial 50, String Functions pt.1

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

4:03 >When you get a vietnam flashback

YTHandle
Автор

50th? hot damn. I'm glad I didn't look linearly through the tutorials for this, or else I would have already been at the end of the semester before I found it.

SangoProductions
Автор

I just wanted to thank you for the tutorials. I am learning a lot from you tutorials, good job!

jtlpe
Автор

"if you print a size_t, make sure to use %u instead of %i" -- *NO! DO NOT do that!* It leads to *undefined behavior.* The *one and only appropriate format specifier* for size_t is "%zu". Nothing else.

HCOSzifon
Автор

Because the size of a pointer (char*) is 4 bytes on a 32-bit machine. Your *str variable is a POINTER, not a char or a string. Since all pointers are either 4-bytes on a 32-bit machine, or 8-bytes on a 64-bit machine, then it will return that size with a pointer

tcbetka
Автор

@lludmill I don't think that there is size_type in C, only in C++. From what I've found on the internet, size_t is guaranteed to be able to store the result of the sizeof operator, and the size_type is guaranteed to be able to hold the length of any string.

iTzAdamX
Автор

I'm not sure if this is what you're asking, but whenever you put some text inside of quotes, the compiler automatically allocates memory for that string and gives you a char* to that memory.

iTzAdamX
Автор

Thanks for the tutorials, I am a little confused about size_t.Could you explain, what is size_t, and what is the difference between size_t and size_type
Thanks

lludmill
Автор

@xSpectrumGaming It really depends on what you're trying to do. C++ will run on any OS and it will run faster. However, C# is easier to learn and write. In my opinion though, C++ is better than C#.

iTzAdamX
Автор

Why not use int instead of size_t, what will be the disadvantage

lludmill
Автор

SO you saying for exaple that we do not have to make an array for the compiler to make a allocatation because the *pointer already does that?

thewhisperinyourears
Автор

at 7:24 he wants to compare the first 3 letters, What if I want to compare the LAST 3 letters? How can I do that?

ex.
1 *bob*
*bob*
I want to scan the last 3 letters of each word.

wowedcanbewowed
Автор

@lludmill If someone had a computer where the size of an int was 2 bytes, then it may not be possible to hold the size of some data structures, like a really big array.

iTzAdamX
Автор

I am a little confused here... Isn't *name a pointer here? if so, why strlen(name) but not strlen(*name) shouldn't that be the dereference of the pointer? Thanks!

michaelwangzim
Автор

there is something wrong when you call the char as a pointer actually you are calling the adress of the string but not the string itself

captainzizo
Автор

i still dont understand why you start with char *name

m.mohammad