File Pointers - CS50 Shorts

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

This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.

***

HOW TO SUBSCRIBE

HOW TO TAKE CS50

HOW TO JOIN CS50 COMMUNITIES

HOW TO FOLLOW DAVID J. MALAN

***

CS50 SHOP

***

LICENSE

CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License

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

fopen: 3:04
fclose 5:17
fgetc: 6:05
fputc: 9:35
fread: 11:24
fwrite: 15:20

@CS50 timestamps per topic on each of the shorts and walk-throughs, like with the lectures, would be great :)

JoeHartshorn
Автор

Love these CS50 shorts. Doug has an incredible talent for teaching.

el_kraken
Автор

Doug Lloyd is the Superman of CS50. He explained things very well that I don't understand from the lectures!

labradoryshockdart
Автор

I'm really grateful for these free, incredibly high-quality online courses. Harvard's my hero for 2020

jjhj_
Автор

I cant tell you how much these videos have helped me 😭😭😭😭 THANK YOU SO MUCH

krys
Автор

This is super informative. You summed up so much in such a short time.

wade
Автор

This is really helpful for understanding the recover problem in pset4

dinoman
Автор

Nice tutorial man, very straightforward

colonizatorgg
Автор

You gotta love Doug's T-shirts though

calintatar
Автор

The following code is incorrect:
char ch;
while ((ch = fgetc(file)) != EOF)
printf("%c", ch);

If we assume EOF <= 255, then there's a problem if the file contains the byte EOF: we would end the while loop as soon as we encounter this magic byte.
Otherwise (EOF > 255), then `ch`, because it is of type char, cannot possibly be > 255. therefore, ch will never be equal to EOF. The loop will never end.

This would be correct:
int ch;
while ((ch = fgetc(file)) != EOF)
printf("%c", ch);

annamaniuk
Автор

Definition of Ephemeral: lasting for a very short time
via google

coffeeisthepathtovictory
Автор

It is possible to use r+, w+ or a+ modes of fopen as well. They open a file for reading and writing, or reading and appending.

TornikeBatavani
Автор

Thank you Doug for another informative short. But one thing in this video has me confused and I need a clarification from someone with a better understanding.
The statement made at the beginning of the video: "File pointers and pointers, while interrelated, are not exactly the same thing." What is being referred to as a 'file pointer' here? Is it the structure, i.e. FILE or the pointer to the structure i.e. FILE*? If it is the latter, isn't it the exact same thing as a pointer? If it is the former, then why in this case alone we've deviating from the convention used in CS50 to place the * closer to the data type and not the variable name? I've read up on the topic and I don't think I have a clear understanding yet, but... as far as I have seen, the FILE structure stores the data about the file, its position in memory on the disk and information for read/write operations such as the point up to which read/write has taken place and so on. Because it points to the file [even if the pointing isn't exactly of the same nature of a regular pointer], this struct is called a 'file pointer'. Our usage of that 'file pointer' i.e. the struct FILE always includes a pointer to that struct, i.e. FILE* because we will be passing it to functions, and because we need to pass by reference and not by value it is important to use 'file pointers' with a pointer to 'file pointers'. Now, I'm not sure if I have grasped this concept. If someone could clarify, I'd be grateful.

amosp
Автор

finals is 2 days, this video is a life saver

Mrkichanpark
Автор

Thank you so much, I was in need for that little bit of information regarding fread, fwrite which you've helped me acquire.

OK-rieu
Автор

it's my 5th time to watch this video and I can't seem to wrap my head around recover

conraduouou
Автор

Мне очень нравится, как доносит информацию Doug Lloyd. Интересно, понятно, плюс примеры Хорошего кода. Спасибо!!!

ejif
Автор

Thank you so much this is so useful and simple 🌹

Maen
Автор

But that loop don't move the pointer?

xrafter
Автор

Honestly how are you supposed to do lab 4 without knowing this? I feel they over-estimate our ability to read documentation, but then again this makes me nervous for documentation in general.

DogginsFroggins