No one is using 16 bit systems. What is pertinent is that the long type is always the word size of the machine It is very common in contemporary compilers to have int and long be the same size. Check: This is why God invented the sizeof operator.
There are eight bits in a byte; byte stands for By-Eight. So 16 bits is equal to 16/8 (16 by 8) bytes, which is 2 bytes. Does that make sense to people? lol :P
At 43:30 he is using a "hack". He casts base to char* and he mentions that it is also possible to use an unsigned long* instead of char*. Why is it possible to use unsigned long*? Unsigned long is a 4 byte datatype, char 1 byte.
Very clear and concise. I dare say he made sense. I much agree with the C comparison to a stick shift too. On the rare occasion of driving an automatic, I find my foot wandering off to some nonexistent clutch (or parking brake) when I come to a stop. One just gets used to the control after awhile and C/C++ offers that control.
@dimipeli Yeah, he does. But sometimes students' questions aren't well-formed and understandable, so as soon as the lecture is being filmed, he has no time for such things. Would you like to see how he tries to understand students' questions for 1 minute or so instead of telling new information? I wouldn't.
yea i think this as well.. and being from stanford they wouldnt make as many mistakes as other "normal" univerisites? Maybe i am wrong? But i do like this teacher! :)
He's good. I actually kind of more appreciate C now for the raw power it puts in the hands of programmers through all the pure bit copying and comparison operations. He actually covers some hacks, like casting to char* to do pointer arithmetic on 1 byte memory space so that normal arithmetic can be done to calculate the correct address offset. The later parts on the Fred and Wilma strings are good as well, shows how C can be abused.
So? Declaring counter variables inside for loops improves readability, and you should do it even if you're restricting yourself to the C subset for whatever reason (in this case, understanding low-level concepts).
If you have a compiler that accepts only ANSI C code, that instruction won't compile. But I'm being too picky I guess... I just wanted to point that out, b/c not many people know about that. I mean, everybody learn C and C++ toghether and think they are the same but they are absolutely not the same.
@3dfabio "After a long and arduous process, the standard was completed in 1989 and ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C", or sometimes "C89" (to distinguish it from C99)."
sizeof(byte7) would be 7 I'm sure, even with an array. Although the memory allocated to storing a single byte7 or an array of byte7 would be aligned to 4 bytes. So if you had an array of 10 byte7 totalling 70 bytes, the compiler will align that to 4 bytes which will make the total allocated space 72 bytes (the extra 2 bytes being padding).
However, if you added another member to that struct the compiler will align the char array member to 8, unless specified otherwise in the compiler settings. So let's say:
struct data
{ char str[7]; int id;
};
sizeof(data) is, under default compiler settings, equal to 12 because the str member has been padded with an extra byte for alignment purposes.
sure it is, you avoid the probability of making mistakes like in 13:10 -> should use sizeof(double), not sizeof(int) which is 2 times smaller on 32bit PCs
This comment has received too many negative votesshow
char buffer[size]? wtf!
if you teach C, write it in C, not in some exotic language, like GCC. Nobody's supposed to write code like that. You'll have enough problems with compatibility of real programs without this GCC shit.
This teacher is awesome. Very concise, linear, and well thought out. Glad he's doing this, passing on his accuracy. one of those jumbled teachers would prolly dive-bomb all these ideas into a mess (or twice as much lecture time).
C rocks. It's like the feeling you get from driving a stick shift....total control! I started with BASIC and Python and thought they were great because they were so easy, almost like using pseudocode. With C I feel like I'm thinking about programming properly and understanding what's going on under the hood. I think an understanding of both C and LISP is essential to becoming a good programmer.
You don't need LISP in a practical sense, but learning it gives you a very valuable understanding of programming from another angle. That's why MIT always used it in their computer science classes and why the classic "Structure and Interpretation of Computer Programs" (available for download online) are taught in LISP. It's a beautiful language which will help you think about programming in a way no other language does.
You gotta give it to this guy, he has great chalkboard technique. Some teachers suck when it comes to writing on a board with chalk but this guy writes like he was born with a piece of chalk in his hand.
Is there a book that treats exactly these subjects? I like listening to this professor, but I feel more comfortable studying on a book.
DeBaimbo 2 weeks ago
where can i find the assignments
shodoilzgon 1 month ago
make sense?? XD jajajajajajajajaja
yeors 1 month ago
The quality of teachers at Stamford is just breathtaking.
TheOkham 2 months ago in playlist Course | Programming Paradigms
This has been flagged as spam show
Give me more! I want to learn mo!
grunder20 2 months ago
This has been flagged as spam show
More english!
grunder20 3 months ago
No one is using 16 bit systems. What is pertinent is that the long type is always the word size of the machine It is very common in contemporary compilers to have int and long be the same size. Check: This is why God invented the sizeof operator.
ncmathsadist 6 months ago in playlist Course | Programming Paradigms
@tapajara haha you fail at acting smart 16 bits is 4 bytes
deathbyaccident 8 months ago
@deathbyaccident
There are eight bits in a byte; byte stands for By-Eight. So 16 bits is equal to 16/8 (16 by 8) bytes, which is 2 bytes. Does that make sense to people? lol :P
Libervurto 6 months ago
You should point out that an "int" is only 16 bits in a 16-bit system. You should be using "long" instead of "int" in your examples.
Tapajara 9 months ago
At 43:30 he is using a "hack". He casts base to char* and he mentions that it is also possible to use an unsigned long* instead of char*. Why is it possible to use unsigned long*? Unsigned long is a 4 byte datatype, char 1 byte.
Martin1456215 1 year ago
Comment removed
Martin1456215 1 year ago
Comment removed
Blobblogger 1 year ago
Very clear and concise. I dare say he made sense. I much agree with the C comparison to a stick shift too. On the rare occasion of driving an automatic, I find my foot wandering off to some nonexistent clutch (or parking brake) when I come to a stop. One just gets used to the control after awhile and C/C++ offers that control.
SomeWeirdFreak 1 year ago
He makes some mistakes here and there, and misinterprets some of the students' questions, but he is still a good lecturer.
dimipeli 1 year ago
@dimipeli Yeah, he does. But sometimes students' questions aren't well-formed and understandable, so as soon as the lecture is being filmed, he has no time for such things. Would you like to see how he tries to understand students' questions for 1 minute or so instead of telling new information? I wouldn't.
SuperGanga2010 1 year ago
@dimipeli
yea i think this as well.. and being from stanford they wouldnt make as many mistakes as other "normal" univerisites? Maybe i am wrong? But i do like this teacher! :)
yoyuepz 11 months ago
Comment removed
dacherx 1 year ago
huh?
silverpizza100 1 year ago
good teaching.
lekimsey 1 year ago
great tutor
crowman131 1 year ago
He's good. I actually kind of more appreciate C now for the raw power it puts in the hands of programmers through all the pure bit copying and comparison operations. He actually covers some hacks, like casting to char* to do pointer arithmetic on 1 byte memory space so that normal arithmetic can be done to calculate the correct address offset. The later parts on the Fred and Wilma strings are good as well, shows how C can be abused.
intj1 1 year ago
I do not get programming at all.
Grundalizer 2 years ago
if thats the case you shouldn't be watching this, it's fairly advanced.
MrHateworker 2 years ago
for (int=0; i<n; i++) is NOT ANSI C!!!!!! you cannot declare a variable anywhere like in C++
tincho81 2 years ago 4
So? Declaring counter variables inside for loops improves readability, and you should do it even if you're restricting yourself to the C subset for whatever reason (in this case, understanding low-level concepts).
uruz0b111 2 years ago
If you have a compiler that accepts only ANSI C code, that instruction won't compile. But I'm being too picky I guess... I just wanted to point that out, b/c not many people know about that. I mean, everybody learn C and C++ toghether and think they are the same but they are absolutely not the same.
tincho81 2 years ago
You can declare variables anywhere in C99, which is ANSI C.
3dfabio 2 years ago
@3dfabio "After a long and arduous process, the standard was completed in 1989 and ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C", or sometimes "C89" (to distinguish it from C99)."
Jurily 1 year ago
it should be for(int i = 0; i < n; i++) ..
and n should be declare before.. by something
chelvan2 2 years ago
Comment removed
mfnickster 2 years ago
...im confused T.T
Rexamallion 2 years ago
I wonder if byte alignment would affect this? Imagine a struct:
struct byte7 { val char[7];
};
And a machine which will only let you start structs at the start of 32 bit boundaries.
Is sizeof(byte7) 7 or 8 on such a machine? If 7, what happens if I have an array of them?
mgrazebrook 2 years ago
sizeof(byte7) would be 7 I'm sure, even with an array. Although the memory allocated to storing a single byte7 or an array of byte7 would be aligned to 4 bytes. So if you had an array of 10 byte7 totalling 70 bytes, the compiler will align that to 4 bytes which will make the total allocated space 72 bytes (the extra 2 bytes being padding).
Continued...
ajito123 2 years ago
However, if you added another member to that struct the compiler will align the char array member to 8, unless specified otherwise in the compiler settings. So let's say:
struct data
{ char str[7]; int id;
};
sizeof(data) is, under default compiler settings, equal to 12 because the str member has been padded with an extra byte for alignment purposes.
ajito123 2 years ago
I think it is better to call this swap function in follwing way:
int main(void)
{ float x, y; swap(&x, &y, sizeof(x)); return 0;
}
As long as x and y have the same type it will work.
AronNimzo 2 years ago
sure it is, you avoid the probability of making mistakes like in 13:10 -> should use sizeof(double), not sizeof(int) which is 2 times smaller on 32bit PCs
osiumjrtosfyo5syerg 2 years ago
bible of C
rhshriva 2 years ago
quite clear, thanks
dragosboros 2 years ago
This comment has received too many negative votes show
char buffer[size]? wtf!
if you teach C, write it in C, not in some exotic language, like GCC. Nobody's supposed to write code like that. You'll have enough problems with compatibility of real programs without this GCC shit.
d001120 2 years ago
Comment removed
guitarfox 2 years ago
This teacher is awesome. Very concise, linear, and well thought out. Glad he's doing this, passing on his accuracy. one of those jumbled teachers would prolly dive-bomb all these ideas into a mess (or twice as much lecture time).
someguyyoudontcare 2 years ago 31
C rocks. It's like the feeling you get from driving a stick shift....total control! I started with BASIC and Python and thought they were great because they were so easy, almost like using pseudocode. With C I feel like I'm thinking about programming properly and understanding what's going on under the hood. I think an understanding of both C and LISP is essential to becoming a good programmer.
NameNotaNumber 2 years ago 36
C is essential, but LISP?
fifachecker 2 years ago
You don't need LISP in a practical sense, but learning it gives you a very valuable understanding of programming from another angle. That's why MIT always used it in their computer science classes and why the classic "Structure and Interpretation of Computer Programs" (available for download online) are taught in LISP. It's a beautiful language which will help you think about programming in a way no other language does.
NameNotaNumber 2 years ago 6
Not any more, they're teaching SICP in Python now.. UGH!!!
YoLninYo 2 years ago
@NameNotaNumber A good programmer knows at least one language from the different programming types.
666friends 1 year ago
he is a genius =))) from him teaching i will be the great, like he =)
abeesk 2 years ago 2
You gotta give it to this guy, he has great chalkboard technique. Some teachers suck when it comes to writing on a board with chalk but this guy writes like he was born with a piece of chalk in his hand.
NameNotaNumber 3 years ago 8
i will be contented to give him all my chalks :) and listen him untill i die :))
abeesk 2 years ago
he says "does that make sense to people" so much it's annoying
g3rc4n 3 years ago
very good lectures
ninja2050 3 years ago 3
Generic programming in pure C, that master is awasome, A genuine programming gettleman XD
bravo!
kbradero 3 years ago
Thank you
badr3001 3 years ago
lol so true lol... i notice that the views keep getting smaller and smaller as u go from lecture 1 - 4 lol wonder y?
invalidacess 3 years ago
Sunday drivers.
NameNotaNumber 3 years ago
yeah me too
availableaccount 3 years ago
This is great thank you
firefokos 3 years ago
I sort of feel bad for him when he got no feedback for his "Does that makes sense to people?" questions.
marsrendezvous 3 years ago 5
this make me sense =))))))))) veeery makes sense =))) it is progressive :)))
abeesk 2 years ago