C Programming Tutorial – 51 – How to Read Files

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

Mushfique Fahim says:

Love from Bangladesh man.

nas damian says:

my last line is printed twice on screen, how to fix it?

laxmi kunwar says:

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

Felix Kimutai says:

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

jhunnen ng says:

can i use excel for the file instead of txt?

Geadz Gaming says:

Last line gets printed twice. Common problem for a lot of people looking at the comments. How do we fix it?

Adam Baker says:

mine wont print anything

King R. Og says:

i am having an error message with fopenfPointer = fopen(“windowsearch.txt”, “jade”);

Muhwezi Titus says:

i liked that

Argad Argad says:

how can I use the File functions to manupilate files other than text files, I tried for a word file but it gives me an error

Jessica Belmares says:

having issues with mac, using text editor and the file name is .rtf putting both .rtf AND .text and its not reading the file.

can you help

I am Jafar says:

Such a cool tutorial video..Love you very much newboston!!!

Ibrahim Khafajy says:

i have code blocks on my apple laptop i can’t read i already created a .txt file inside my folder but it doesn’t read. is there something that i should change from setting n those stuff?

Str4yshot says:

How would you store the line you read to another variable?

Felipe André says:

MITH!
thanks mate, haha.

Amith Nagaraj says:

Someone help me out the last line is printed twice

Antonio TF says:

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

blackneos940 says:

I’m very familiar with C now (and I have you, among others to thank for that, along with constant training in C)….. 🙂 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 worked!….. 🙂 Now, thanks to this Video (I can’t believe I didn’t find it early on in my Coding-fu practice), I have learned how….. 🙂 You *really* are incredible, you know that, Bucky…..? 😀

Error says:

Yo dawg, I get the last line in my phile output twice. wtf?

ahmet celtik says:

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 😛

Best of Everything says:

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

Eria Ardwen says:

I have this problem when I try to compile your code using MinGW:

programming_tutorials.c:13:17: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
puts;

In file included from programming_tutorials.c:2:0:
c:mingwincludestdio.h:357:37: note: initializing argument 1 of ‘int puts

What does it mean?

kareem sameh says:

thanks !!!!!!!!!!!!!!!!!!!!!!

Aristotelis Tsiolakis says:

so every time fgets is executed the things stored in singleline are deleted and so it copies the things from the next line?
because singleline when executied the second time should print i love bacon(from before) i loce bacon(the new) and i really like to eat meatballs and so on the third time.

Gizem Özdemir says:

Thank you !

Adrian Santosa says:

Can someone explain what the “!” Is for before the feof(file end of file)?

Aristokles says:

I have tried to use printf(“%s”,singleLine); instead of puts(singleLine). Then there was no extra enter.
Will you tell me, if i use printf as string. Will it create any problem on large program

Roberto Melo says:

prints the last line twice

Jorge Castro says:

If I wanted to only print the 1st line

Or scan the file and only print specific info

what do I do ?

Andy D. says:

Very clear and simple to understand!!! Greta job (y) (y)

Miles The coder says:

How would you do it with images

Haphyz Gbenle says:

having trouble reading from an excel file is there anything I need to know about excel files that can help

Ahmad Sadman says:

the letters are so small in your video. i can’t see it. please zoom your camera or bold your letters. but you did a really good job

Kojo Numafo says:

I need help my code keeps crahing and i don’t know why. Here the code:

#include
#include

int main()
{
FILE * fp;
fp = fopen(“textfile.txt”,”r”);
char files[100];
while(!feof(fp)){
fgets(files,100,fp);
puts(files);
}
fclose(fp);
return 0;
}

Lieutenant Silver says:

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.

Tobby mp4 says:

what drugs were these guys on when they made C? ( discussing in built functions. )

mrstanlez says:

Hi, I have trouble with file exist under C, with fopen and bitmap. Can You help me please ?

kyriacos herakleous says:

i am using codeblocks with tiny c compiler as requested by teacher in school. i cant get it to work. my problem is that it read the file but in other language or something. for example. i write in the txt file i love chicken, and it gives me multiple lines of 4[]0 kind of letters what can i do please help i need to deliver this in 2 days

Ern-Min Peck says:

Must I put my text file in a specific location?

Eddy Eule says:

love your vids, keep on !!

Stelios Papoutsakis says:

what if you want to search a file for a character, or a word and find out how many times it repeats itself in the file? and say we want to change the space between the words with another symbol? count the file size and say the character h is 0,2% from the total file?

Rares Oance says:

if you use fscanf to read and then fgets, there’s a chance that your keyboard buffer has a n in it so you have to do a fgetc to clear the buffer, thought it was worth mentioning

Vascolas007 says:

it says segmentation fault: 11

Jonathan Tshimpaka says:

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.

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!