C Programming Tutorial - 51 - How to Read Files

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

can we just take a minute to appreciate that he's making these videos for us at 6:30 am?

matthewpenner
Автор

You are AMAZING. Please continue your work. Your videos are clear, to the point and fun to follow. Thank you for taking time out of your day to do this.

SamSolutionsInc
Автор

Dude you are a lifesaver, my Italian lecturer has no idea on how to teach reading and writing to files and stuff, I was completely lost until I found you. Great tutorials and you deserve more subscribers than you have now :P

ahmetceltik
Автор

you know what dude you changed the boring chapters into intresting chapters
thanks for these videos
keep goin on

laxmikunwar
Автор

If you have trouble with the last line printing twice, I have a slight fix to Bucky's code!

while(fgets(singleLine, 50, fPointer)!=NULL){
puts(singleLine);
}

OlaKveli
Автор

Adin Begovic you have to safe the file you are creating and the bacon.txt in a same folder. Don't get confused bacon.txt that you want to read and .c file you are creating now must be in a same folder otherwise you will get nothing or see nothing.
I created file from an email that i sent to my friend and saved as a txt file and this is how i have done it
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE * fp;
fp = fopen("Jaylawrence.txt", "r");
char singleLine[150];

while(!feof(fp)){
fgets(singleLine, 150, fp);
puts(singleLine);
}
fclose(fp);
return 0;
}
it worked for me.

Thanks Bucky! I know this video was created a year Ago 8/6/2014 but we are still
benefiting.

AbdiShibis
Автор

After litterally no joke 2 days of researching I finally found the answer on how to put file contents into a string.

JushBJJ
Автор

Thank you so much for your content dude!!! I missed like 2 or 3 classes thanks to volunteering, and I missed so much, but you're helping me catch up! Woo College! Keep it up

Rank__Rider
Автор

sweet tutes bukey. Love your informal/friendly style of teaching.

missiona
Автор

I say it again, you are the best, my program was giving me headache, but I got it right after watching your video. Thanks.

felixkimutai
Автор

I kind of find it funny that he uses a lot of food name in his example like "bacon, cheese, ham etc..." haha, but I love your videos man. Keep doing what you do, It helps me a lot.

Jonathan-qztd
Автор

guys, if you have troubles with the space between the lines, you can use

printf("%s", singleLine);

instead of that "puts" function

jakasha
Автор

Thank I've been stuck on this for hours. you are a life saver man!

willsanchez
Автор

You don't even need feof in while, just write fgets in while like this:

while(fgets(singleLine, 150, fPointer) printf("%s\b", singleLine);

fgets won't get any text if it comes to the end and returns 0, therefore the while is broken, and the \b will remove the \n so no space after puts

limitess
Автор

Is there a way to read specific parts of the file? Say you need certain numbers from the file and display them in your program.

Embrcoocli
Автор

I'm very familiar with C now (and I have you, among others to thank for that, along with constant training in :) But, after a long time of doing Programming (about 3 or 4 Years), I STILL couldn't wrap my Mind around how not just opening, but actually printing a File's contents to SCREEN :) Now, thanks to this Video (I can't believe I didn't find it early on in my Coding-fu practice), I have learned :) You *really* are incredible, you know that, :D

blackneos
Автор

I was wandering on YouTube for this for 30 minutes

Got the answer in 5 minutes from this

suneelpandita
Автор

The last line "cheese" printed twice. Cause seems to be a \n-command at the end of cheese in bacon.txt. The loop reached the new line after cheese, had nothing to read in that line and printed "cheese" again. After removing \n, the while-loop acted normal.

LieutenantSilver
Автор

One year has passed ... Make some more stuff. Please missing you Roberts

radioactive
Автор

dude, you saved me twice this year lol thanks for the vids!

gamesmaker