strcmp() function | C Programming Tutorial

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

I watched 5+ videos about strcmp but only this one explain well because some other tutorials i watched they're like explaining to learner that already knowledge in strcmp. Thankyou!

virgo
Автор

this is the only guy who doesn't codes in dark mode😂

lyrichives
Автор

I am israeli man and i dont know english fluently. however, i succed to understand your tuorial!!
tank you!

nadavAminov
Автор

awesome content😃😃
my school prof tried his best to teach me this topic but dumb me couldn't understand anything..
thank you so much😎😎

misterrandompro
Автор

So well spoken. Brilliant video. Thank you so much!

matthewbnguyen
Автор

Nice video. Thanks :)
Whats funny to me is that if you wanted to just compare 1 specific character in a string something like this would work:
char message [ ] = "Hello";
char greeting [ ] = "Hey";

if (message[0] == greeting[0]){
printf("Character 0: Huzzah! Equality\n");
}
else {
printf("Character 0: Nah, not equal\n");
}

If you wanted to compare a specific place in the strings you might use something like this, rather than strcmp. Pretty neat.

Ithicuss
Автор

It looks like strcmp does a subtraction. When the subtraction (s1-s2) is non-zero, then the returned number is the difference at that point between the two ASCII values. So "abc" an "abd" would give -1. "abc" and "abm" gives -10, the difference in the ASCII representations of 'c' (99) and 'm' (109) Might turn out useful....

baruchben-david
Автор

What's the preprocessor directives for strcmp? It says i should have a prototype

renzrafaelvillasoto
Автор

What happens if you try to dereference the strings to point refer to the string values instead of the addresses?

stephenhumphrey
Автор

built this, i want some feedback:
int str_cmp(const char* str1, const char* str2) {
size_t str1_length = strlen(str1);
size_t str2_length = strlen(str2);
if (str1_length == str2_length) {
for (size_t i = 0; i < str1_length; i++) {
if (str1[i] != str2[i]) {
if (str1[i] > str2[i]) {
1;
} else {
-1;
}
}
}
} else {
int min_len = (str1_length > str2_length ? str2_length : str1_length);

for (size_t i = 0; i < min_len; i++) {
if (str1[i] > str2[i]) {
return 1;
} else {
return -1;
}
}

return (min_len == str1_length ? -1 : 1);
}

return 0;
}

deepblackoutlaw
Автор

Of course he has a video on it :) Will definitely donate through the "Thanks button". (Soon). I will send like 30 usd.

X-VIPRIN
join shbcf.ru