Download "C reading files 🔎"

Download this video with UDL Client
  • Video mp4 HD+ with sound
  • Mp3 in the best quality
  • Any size files
Video tags
|

Video tags

language
for
beginners
youtube
lesson
tutorial
lectures
arrays
functions
pointers
structures
how
to
learn
education
class
C (Programming Language)
Computer Programming (Conference Subject)
How-to (Website Category)
c
read
file
Subtitles
|

Subtitles

00:00:02
all right people so in this video i'm
00:00:04
going to show you how we can read the
00:00:05
contents of a file someplace on your
00:00:07
computer you can either place this
00:00:09
within the same folder as your c program
00:00:12
or someplace else i think it would be
00:00:13
cool if we read a file from our desktops
00:00:16
so i'm going to create a new file and
00:00:18
this is going to be a plain text file
00:00:20
and i'll write a poem i'll name this
00:00:22
poem.txt
00:00:24
here's my beautiful poem
00:00:26
roses are red
00:00:29
violets are blue
00:00:32
booty booty booty booty
00:00:37
rockin
00:00:38
everywhere
00:00:40
okay i'm going to save
00:00:42
and then i'll need the file location of
00:00:44
where this is located i'm going to right
00:00:46
click go to properties and copy this
00:00:48
file path and save it for later now to
00:00:51
read a file on your computer we'll need
00:00:53
to create a pointer the data type is
00:00:56
file
00:00:57
and i'll name this
00:00:58
p
00:00:59
f and i will set the sequel to then
00:01:01
invoke the f open function
00:01:04
pass in your file mine is
00:01:07
poem.txt
00:01:08
so if this file is not within the same
00:01:11
folder as your c program you'll need a
00:01:13
relative or absolute file path since
00:01:16
this file is on my desktop i could use
00:01:19
an absolute file path
00:01:20
so preceding my file name i will paste
00:01:23
that location and then each backslash
00:01:26
may need to be a double backslash
00:01:28
because that is an escape sequence for a
00:01:30
backslash character okay the second
00:01:32
argument is the mode this time we are
00:01:35
going to read a file so pass in r for
00:01:38
the second argument then it's good
00:01:40
practice at the end of your program to
00:01:42
close any open files
00:01:45
we will invoke the f close function pass
00:01:47
in our pointer do not dereference it and
00:01:50
we will need one more thing a buffer a
00:01:53
buffer is going to act as a container an
00:01:56
array of characters to hold one line of
00:01:58
our text document one line at a time so
00:02:01
let's declare an array of characters
00:02:03
named buffer and i'll set the size
00:02:06
to 255 our buffer is going to hold one
00:02:10
line of our file one line at a time and
00:02:12
to read a single line from our file we
00:02:15
will use the f gets function and there
00:02:18
are three arguments our buffer this is
00:02:21
what we're inserting a line of text into
00:02:24
a maximum input size i'll set this to be
00:02:26
255 to match our buffer and then a
00:02:29
pointer to the file that we're opening
00:02:32
and again make sure to not dereference
00:02:34
it so this will read a single line of
00:02:36
text and then let's print our buffer so
00:02:39
we're printing a string and we are
00:02:41
displaying whatever is currently within
00:02:43
our buffer
00:02:44
so after running this this will read a
00:02:46
single line of text whatever's at the
00:02:49
top roses are red
00:02:51
now if i need to read all of the
00:02:53
contents of my file i can place this
00:02:56
section of code within a while loop
00:03:01
so with our condition i'm going to move
00:03:04
the f gets function within the condition
00:03:07
if we reach the end of a file f gets
00:03:09
will return null so let's continue this
00:03:12
while loop while f gets does not return
00:03:15
no if we do not return null then we will
00:03:18
print whatever's within our buffer now
00:03:20
if i run this this will display all of
00:03:23
the lines from my file roses are red
00:03:26
violets are blue booty booty booty booty
00:03:28
rocking everywhere and if you would like
00:03:30
you can add a little bit of file
00:03:31
detection so before we reach our while
00:03:34
loop let's check to see if that file
00:03:36
even exists before we attempt to open
00:03:38
and read it so let's check to see if our
00:03:41
pointer equals no if it is null that
00:03:44
means we could not locate this file
00:03:46
so i'm going to print
00:03:49
unable to open
00:03:51
file
00:03:53
and we'll create an else statement
00:03:55
else let's read and print the contents
00:03:58
of this file
00:04:02
okay so let's say i get the file
00:04:03
extension wrong let's say i'm looking
00:04:05
for an html file named poem and i try
00:04:08
and read this
00:04:10
unable to open file but if we are able
00:04:12
to locate this file
00:04:14
we will open it and read the contents
00:04:17
and then close this file so yeah
00:04:19
everybody that is how to read the
00:04:21
contents of a file line by line if you
00:04:23
found this video helpful please be sure
00:04:25
to help me out by smashing that like
00:04:27
button leave a random comment down below
00:04:29
and subscribe if you'd like to become a
00:04:30
fellow bro

Description:

C read a file tutorial example explained int main() { FILE *pF = fopen("poem.txt", "r"); char buffer[255]; if(pF == NULL) { printf("Unable to open file!\n"); } else { while(fgets(buffer, 255, pF) != NULL) { printf("%s", buffer); } } fclose(pF); return 0; }

Mediafile available in formats

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

question iconHow can I download "C reading files 🔎" video?arrow icon

    http://univideos.ru/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

    The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

    UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

    UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

question iconWhich format of "C reading files 🔎" video should I choose?arrow icon

    The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

question iconWhy does my computer freeze when loading a "C reading files 🔎" video?arrow icon

    The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

question iconHow can I download "C reading files 🔎" video to my phone?arrow icon

    You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

question iconHow can I download an audio track (music) to MP3 "C reading files 🔎"?arrow icon

    The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

question iconHow can I save a frame from a video "C reading files 🔎"?arrow icon

    This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

question iconHow do I play and download streaming video?arrow icon

    For this purpose you need VLC-player, which can be downloaded for free from the official website https://www.videolan.org/vlc/.

    How to play streaming video through VLC player:

    • in video formats, hover your mouse over "Streaming Video**";
    • right-click on "Copy link";
    • open VLC-player;
    • select Media - Open Network Stream - Network in the menu;
    • paste the copied link into the input field;
    • click "Play".

    To download streaming video via VLC player, you need to convert it:

    • copy the video address (URL);
    • select "Open Network Stream" in the "Media" item of VLC player and paste the link to the video into the input field;
    • click on the arrow on the "Play" button and select "Convert" in the list;
    • select "Video - H.264 + MP3 (MP4)" in the "Profile" line;
    • click the "Browse" button to select a folder to save the converted video and click the "Start" button;
    • conversion speed depends on the resolution and duration of the video.

    Warning: this download method no longer works with most YouTube videos.

question iconWhat's the price of all this stuff?arrow icon

    It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.