File Pointers - CS50 Shorts

  Рет қаралды 155,551

CS50

CS50

Күн бұрын

***
This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.
***
HOW TO SUBSCRIBE
www.youtube.com...
HOW TO TAKE CS50
edX: cs50.edx.org/
Harvard Extension School: cs50.harvard.e...
Harvard Summer School: cs50.harvard.e...
OpenCourseWare: cs50.harvard.e...
HOW TO JOIN CS50 COMMUNITIES
Discord: / discord
Ed: cs50.harvard.e...
Facebook Group: / cs50
Faceboook Page: / cs50
GitHub: github.com/cs50
Gitter: gitter.im/cs50/x
Instagram: / cs50
LinkedIn Group: / 7437240
LinkedIn Page: / cs50
Reddit: / cs50
Quora: www.quora.com/...
Slack: cs50.edx.org/s...
Snapchat: / cs50
Twitter: / cs50
KZbin: / cs50
HOW TO FOLLOW DAVID J. MALAN
Facebook: / dmalan
GitHub: github.com/dmalan
Instagram: / davidjmalan
LinkedIn: / malan
Quora: www.quora.com/...
Twitter: / davidjmalan
***
CS50 SHOP
cs50.harvardsh...
***
LICENSE
CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
creativecommon...
David J. Malan
cs.harvard.edu...
malan@harvard.edu

Пікірлер: 85
@JoeHartshorn
@JoeHartshorn 4 жыл бұрын
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 :)
@AlqantDBlank
@AlqantDBlank 3 жыл бұрын
hero
@danivanon
@danivanon 2 жыл бұрын
e·phem·er·al - lasting for a very short time 0:08
@Balidor
@Balidor 2 жыл бұрын
Yes please, it would be very usefull as we always come back to them :D
@asmgutinho
@asmgutinho Жыл бұрын
Thanks a lot man!!!!
@labradoryshockdart9734
@labradoryshockdart9734 Жыл бұрын
Doug Lloyd is the Superman of CS50. He explained things very well that I don't understand from the lectures!
@sefonefinpsefnpefn4191
@sefonefinpsefnpefn4191 Жыл бұрын
he is a legend! his explanation is so clear!
@TobiasR-ig3pb
@TobiasR-ig3pb 5 ай бұрын
They are all legends
@el_kraken
@el_kraken 5 жыл бұрын
Love these CS50 shorts. Doug has an incredible talent for teaching.
@jjhj_
@jjhj_ 4 жыл бұрын
I'm really grateful for these free, incredibly high-quality online courses. Harvard's my hero for 2020
@merry1195
@merry1195 Жыл бұрын
2023 too
@user-ex5pg3oy9c
@user-ex5pg3oy9c 10 ай бұрын
2025 here
@shaanssonnets430
@shaanssonnets430 7 ай бұрын
@@user-ex5pg3oy9c 😂
@krys6544
@krys6544 6 жыл бұрын
I cant tell you how much these videos have helped me 😭😭😭😭 THANK YOU SO MUCH
@jayant9151
@jayant9151 6 жыл бұрын
Krystal Danielle why crying
@wol2231
@wol2231 5 жыл бұрын
@@jayant9151 It's called tears of joy.
@seal0118
@seal0118 5 жыл бұрын
bruh these videos actually help
@wade3696
@wade3696 Жыл бұрын
This is super informative. You summed up so much in such a short time.
@Firnila
@Firnila 4 жыл бұрын
Doug, you wonderful human being.
@dinoman6481
@dinoman6481 2 жыл бұрын
This is really helpful for understanding the recover problem in pset4
@lunarskiy
@lunarskiy 3 жыл бұрын
Thanks, Doug! Amazing explanation!😎
@colonizatorgg5960
@colonizatorgg5960 5 жыл бұрын
Nice tutorial man, very straightforward
@florentjung5799
@florentjung5799 4 жыл бұрын
Doug you are my hero !
@coffeeisthepathtovictory1290
@coffeeisthepathtovictory1290 4 жыл бұрын
Definition of Ephemeral: lasting for a very short time via google
@Mrkichanpark
@Mrkichanpark 4 жыл бұрын
finals is 2 days, this video is a life saver
@TornikeBatavani
@TornikeBatavani 2 жыл бұрын
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.
@OK-ri8eu
@OK-ri8eu 2 жыл бұрын
Thank you so much, I was in need for that little bit of information regarding fread, fwrite which you've helped me acquire.
@terra_h4429
@terra_h4429 4 жыл бұрын
I legendarily love Doug.
@calintatar
@calintatar 3 жыл бұрын
You gotta love Doug's T-shirts though
@joncolumbino744
@joncolumbino744 4 жыл бұрын
this guy is a god
@conraduouou
@conraduouou 4 жыл бұрын
it's my 5th time to watch this video and I can't seem to wrap my head around recover
@morpy3077
@morpy3077 4 жыл бұрын
bruh same
@matnreyes
@matnreyes 4 жыл бұрын
Same, I've no idea how these work
@bencooper2753
@bencooper2753 4 жыл бұрын
@@matnreyes Same
@ashish2099
@ashish2099 4 жыл бұрын
At first I too was confused about what those ptr2 thing was, but turned out it was just a pointer to an address. fread reads info from that pointer block (the file handle we opened as "r") to buffer (simply said the variable we have declared) and fwrite takes info from buffer to pointer.
@liriocoentro
@liriocoentro 4 жыл бұрын
Thankfully just problem set 7 was changed, so I'll be able to finish this course this year. I started in june 2020. Good luck to you all, fellow coders.
@mehdiahmed7836
@mehdiahmed7836 3 жыл бұрын
Amazing explanation , thanks doug ❤️
@fidalgoverde
@fidalgoverde 4 жыл бұрын
Excellent details and explanation
@annamaniuk6265
@annamaniuk6265 5 жыл бұрын
The following code is incorrect: char ch; while ((ch = fgetc(file)) != EOF) printf("%c", ch); If we assume EOF
@ryukthegodofdeath8063
@ryukthegodofdeath8063 4 жыл бұрын
You are right it needs to be int instead of char.
@huanghowie4570
@huanghowie4570 4 жыл бұрын
totally right thanks bro
@kjpg2005
@kjpg2005 4 жыл бұрын
Indeed, char did not work correctly. It only copies part or none of the source image.
@xrafter
@xrafter 4 жыл бұрын
Yes man you are right thanks for the knowledge
@Drifting_Turtle
@Drifting_Turtle 4 жыл бұрын
According to the authors of the C Programing Language (Brian W. Kernighan, Dennis M. Ritchie): "We use int for a subtle but important reason. The problem is distinguishing the end of the input from valid data. The solution is that getchar returns a distinctive value when there is no more input, a value that cannot be confused with any real character. This value is called EOF, for "end of file". We must declare c to be a type big enough to hold any value that getchar returns. We can't use char since c must be big enough to hold EOF in addition to any possible char. Therefore we use int" (The C Programming Language, 2nd edition, p. 16).
@ybleon7131
@ybleon7131 7 жыл бұрын
great explanation! Thank you!
@ejif2
@ejif2 5 жыл бұрын
Мне очень нравится, как доносит информацию Doug Lloyd. Интересно, понятно, плюс примеры Хорошего кода. Спасибо!!!
@sashabachynskyi8931
@sashabachynskyi8931 4 жыл бұрын
Закончили ли вы курс cs50?
@ejif2
@ejif2 4 жыл бұрын
@@sashabachynskyi8931 Здравствуйте) Стыдно признаться, завис на JavaScript. Уже два месяца собираюсь добить)) Есть оправдание - я закончил оффлайн курсы по JavaScript и работаю fullstack developer'ом на React + Node.js ))
@aquere
@aquere 4 жыл бұрын
@@ejif2Можете дать телеграм? Интересно узнать как у вас так вышло устроиться фуллстаком за такое короткое время с начала прохождения курса cs50)
@ejif2
@ejif2 4 жыл бұрын
@@aquere Я не показатель. Я начинал в 1993году, потом бросал на 20 лет. Случились в жизни изменения, посмотрел, что не сделал за прошлую часть жизни, решил "добить" начатое. Начал с CS50, потом поступил на оффлайн курсы по JavaScript. Сейчас работаю JavaScript программистом.
@juliabeseda1088
@juliabeseda1088 4 жыл бұрын
А я наоборот смотрела и думала о том, как же скучно он рассказывает..)) Когда лекции ведет Дэвид, оторваться невозможно, а вот с Дагом я больше двух минут не могу удержать концентрацию, приходится ставить на паузу и делать перерыв)
@Maen963
@Maen963 6 жыл бұрын
Thank you so much this is so useful and simple 🌹
@andreamacias1533
@andreamacias1533 2 жыл бұрын
we love you Doug!
@amosp9120
@amosp9120 Жыл бұрын
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.
@omergulcu
@omergulcu Жыл бұрын
It seems like you understood it quite well. File pointers (for example FILE *input) are pointers, they just point to files and somehow also store stuff like what to you opened the file dor (w, r) and where you are in the file. They are pointers themselves and they are exactly what functions like fread and fwrite need, I don't think there's need to complicate this further.
@zchforward
@zchforward Жыл бұрын
This part is crazy hard
@reebakhan2685
@reebakhan2685 6 жыл бұрын
Thanks, it is just great.
@GOODBOY-vt1cf
@GOODBOY-vt1cf 4 жыл бұрын
thank you so much
@marekpumex
@marekpumex Жыл бұрын
Thank You :)
@not_amanullah
@not_amanullah 9 ай бұрын
Thanks
@iamabutalhakhalil
@iamabutalhakhalil Жыл бұрын
hats off
@BaturCihan
@BaturCihan 3 жыл бұрын
thank u!
@tranthetam
@tranthetam 4 жыл бұрын
13:51 bookmark fread() example
@xrafter
@xrafter 4 жыл бұрын
But that loop don't move the pointer?
@DogginsFroggins
@DogginsFroggins 2 жыл бұрын
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.
@tibigraz
@tibigraz 2 жыл бұрын
This video is part of Week 4 but you may overlooked, there's a "shorts" page BEFORE problem sets every week and you need to watch all of them in order to get green arrows for that week.
@coltonfox8689
@coltonfox8689 4 жыл бұрын
10:50 If ptr2 already contained data, wouldn't fputc(ch, ptr2) append ch to the end of ptr2 vs replace? I thought the Linux cp command overwrites whatever you copy something to
@PausBastianus
@PausBastianus 4 жыл бұрын
Only if ptr2 was opened using fopen(file2.txt, a). If it was opened using w, it would overwrite any existing data. Check 4:28 . There he opens file2.txt with the w operator.
@xrafter
@xrafter 4 жыл бұрын
@@PausBastianus Yeah i read about file pointers they point to the start of the file whatever the file is but if you add append it always will start at the end
@kaliomar5988
@kaliomar5988 5 жыл бұрын
great explanation thanks,
@sarahmedouni8844
@sarahmedouni8844 2 жыл бұрын
i made a file with fopen then wanted to print the contents into the terminal with fgetc and it didn't return anything, anyone know why?
@sarahmedouni8844
@sarahmedouni8844 2 жыл бұрын
it was because i was using "w" for write 😅
@nilaksh007
@nilaksh007 4 жыл бұрын
9:08 this code is not working
@Drifting_Turtle
@Drifting_Turtle 4 жыл бұрын
See Anna Maniuk comment bellow explaining this issue
@henny1986
@henny1986 4 жыл бұрын
Is fread() like fgetc() in that it reads the NEXT block of bytes?
@xrafter
@xrafter 4 жыл бұрын
No fread read n bytes from keyboard fgetc only read on byte
@xrafter
@xrafter 4 жыл бұрын
What is the difference between syscalls functions and this? Is it the same ?
@joaquin8118
@joaquin8118 4 жыл бұрын
so in 12:38 it says that what you read is stored in arr. my question is, in what part of the array the reading is stored? is it in arr[0]? is it in arr[9]? how do i know where it is?
@stevefranzreb856
@stevefranzreb856 4 жыл бұрын
I'm still learning this stuff (why I'm here...), but I think this is correct. In "fread(arr, sizeof(int), 10, ptr)", "arr" is the pointer that points to the array "arr[10]" that was declared in "int arr[10]". The pointer of an array is always the 0th element of the array. When we declared it, we said it will be an array of integers. We are fread()ing a quantity of 10 chunks of memory that are sizeof(int) bytes. That tells me that, from the file we are fread()ing, we are pulling 10 ints, thus filling the array "arr[10]". So, the first chunk of "sizeof(int)" (4) bytes, goes in arr[0], the second chunk goes in arr[1], etc.
@xrafter
@xrafter 4 жыл бұрын
Heh every one knows that the header file is just a declerations and macros. The definitions are in binary files
@honestlee4532
@honestlee4532 Жыл бұрын
The cat.c file mentioned in the middle of this video has a BAD choice for a filename! If you make a file called cat.c and then make the file, you end up with an executable called 'cat.' A much better name would be something that does NOT match the name of an already existing command. So something like 'mycat' , 'ccat', or 'cats' would be much better. Also, if you look at the code... char ch; while ((ch = fgetc(ptr)) != EOF) printf("c", ch); The above code is INCOMPLETE. This is exactly why you DON'T want a command with the same name of one that already works. The code mentions 'ptr' which has NOT been assigned according to this little bit of code. Making cp.c is ALSO a BAD idea. Using the name of a Linux command on a Linux system is a POOR choice and using the name of a Windows command on a Windows computer is also a BAD idea.
@xrafter
@xrafter 4 жыл бұрын
Is double even valid for reading integers?
@drenhyseni6633
@drenhyseni6633 6 ай бұрын
I don't think cp was a good name for a comand :p
@Ss-zg3yj
@Ss-zg3yj Жыл бұрын
EOF is not a character
Pointers - CS50 Shorts
29:18
CS50
Рет қаралды 210 М.
Flask - CS50 Shorts
17:19
CS50
Рет қаралды 41 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
you will never ask about pointers again after watching this video
8:03
Recursion - CS50 Shorts
13:50
CS50
Рет қаралды 175 М.
File Access Basics | C Programming Tutorial
24:05
Portfolio Courses
Рет қаралды 110 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
I Spent 100 Hours Inside The Pyramids!
21:43
MrBeast
Рет қаралды 42 МЛН
How to Stop Procrastinating and Finally Take Action
16:31
Ali Abdaal
Рет қаралды 126 М.
Singly-Linked Lists - CS50 Shorts
23:23
CS50
Рет қаралды 103 М.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 306 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН