
Memory - Intro to Computer Science - Harvard's CS50 (2018)
video description
Date: 2022-03-14
Related videos
Comments and reviews: 10
freecodecamp
That Compare2.c program did not work for me at all the way he did it.
I had to modify it slighly for some reason.
to this instead
#include -
#include -
#include -
bool compare_strings(string a, string b);-
int main(void)-
--
string s = get_string(-s: -);-
string t = get_string(-t: -);-
if (compare_strings(s,t))-
--
printf(-Same\n-);-
--
else -
--
printf(-Different\n-);-
--
--
bool compare_strings(string a, string b)-
--
if (strlen(a) != strlen(b))-
--
return false;-
--
int n = strlen(a);-
int i;-
for (i = 0; i < n; i++)-
--
if (a[i] != b[i])-
--
return false;-
--
--
return true;-
-
reply
That Compare2.c program did not work for me at all the way he did it.
I had to modify it slighly for some reason.
to this instead
#include -
#include -
#include -
bool compare_strings(string a, string b);-
int main(void)-
--
string s = get_string(-s: -);-
string t = get_string(-t: -);-
if (compare_strings(s,t))-
--
printf(-Same\n-);-
--
else -
--
printf(-Different\n-);-
--
--
bool compare_strings(string a, string b)-
--
if (strlen(a) != strlen(b))-
--
return false;-
--
int n = strlen(a);-
int i;-
for (i = 0; i < n; i++)-
--
if (a[i] != b[i])-
--
return false;-
--
--
return true;-
-
reply
Matt
I feel a bit mixed about this.
I am a software engineer. I have been for a time.
I have taken (and aced) countless CS courses while in school but I still have profound insight watching this supposed by number a 'half-assed CS' series...I get it, not advanced material but damn, it is so complete in layers for such a short class.
Did I spend a fortune for nothing??
I love the memory and data structures talks best:)
reply
I feel a bit mixed about this.
I am a software engineer. I have been for a time.
I have taken (and aced) countless CS courses while in school but I still have profound insight watching this supposed by number a 'half-assed CS' series...I get it, not advanced material but damn, it is so complete in layers for such a short class.
Did I spend a fortune for nothing??
I love the memory and data structures talks best:)
reply
cyborgdale
The RETURN statement. He doesn't elaborate.
int main (void)-... means that the return value is an integer and there are no arguments. This works in all compilers. Some compilers have an implicit - - return 0; - at the end but it is best practice to include it.
void main(void) -... is allowed in some compilers but not all. This should be avoided for compatibility reasons.
zero = GOOD --- !zero = BAD
reply
The RETURN statement. He doesn't elaborate.
int main (void)-... means that the return value is an integer and there are no arguments. This works in all compilers. Some compilers have an implicit - - return 0; - at the end but it is best practice to include it.
void main(void) -... is allowed in some compilers but not all. This should be avoided for compatibility reasons.
zero = GOOD --- !zero = BAD
reply
Adrian
at 1:23:35 the professor feels lucky, but is actually not. scanf with %s means -String of characters. This will read subsequent characters until a whitespace is found-. So even if you entered a lot of characters after -David -, because it's a whitespace after David, it prints ok. The segmentation fault example after that is due to the fact that are no spaces.
reply
at 1:23:35 the professor feels lucky, but is actually not. scanf with %s means -String of characters. This will read subsequent characters until a whitespace is found-. So even if you entered a lot of characters after -David -, because it's a whitespace after David, it prints ok. The segmentation fault example after that is due to the fact that are no spaces.
reply
remy
At 45:00 a way better solution would be not to check strlength() first because it actually already has to scan the entire word until it finds a -\0-. Also, do not include a new for loop with strlenght in it. Simply create a While loop that checks the words char by char, until one (or both) end up being -\0-.
reply
At 45:00 a way better solution would be not to check strlength() first because it actually already has to scan the entire word until it finds a -\0-. Also, do not include a new for loop with strlenght in it. Simply create a While loop that checks the words char by char, until one (or both) end up being -\0-.
reply
Malvin
Now I know why Bill Gates Left Harvard.
So as Mark Zuckerberg.
Segmentation Fault is an Error from Operating System.
Stack Overflow can be resolved by hard disks or external memories allocations.
reply
Now I know why Bill Gates Left Harvard.
So as Mark Zuckerberg.
Segmentation Fault is an Error from Operating System.
Stack Overflow can be resolved by hard disks or external memories allocations.
reply
rei.
Okay, what's the difference between these two declaration of strings?
char -foo;
or
char foo[10];
This made me even more confused, when should I use the later, or the former?
reply
Okay, what's the difference between these two declaration of strings?
char -foo;
or
char foo[10];
This made me even more confused, when should I use the later, or the former?
reply
Souligna
Thank you for explaining pointers in different way, I understand so much in this video. Had to watch it twice to memorize the concept, but the teacher is so good at explaining this.
reply
Thank you for explaining pointers in different way, I understand so much in this video. Had to watch it twice to memorize the concept, but the teacher is so good at explaining this.
reply
Eissa
Nice, Can I get certification from this university (actually remotely even if paid) without wasting time from going from place to place............
reply
Nice, Can I get certification from this university (actually remotely even if paid) without wasting time from going from place to place............
reply
George
-freecodecamp, videos 5 and 6 in the CS50 playlist are not playable, as it says they are private videos and they can't be displayed.
reply
-freecodecamp, videos 5 and 6 in the CS50 playlist are not playable, as it says they are private videos and they can't be displayed.
reply
Add a review, comment
Other channel videos















