#29: C File Handling | C Programming for Beginners

  Рет қаралды 188,047

Programiz

Programiz

Күн бұрын

Пікірлер: 107
@programizstudios
@programizstudios 2 жыл бұрын
🚀 Loved the tutorial? Take it further with Programiz PRO! Refine your skills, conquer coding fears, and build confidence with interactive lessons, quizzes, and challenges. Strengthen your programming foundation and master C today! 👉Start Here: bit.ly/c-master
@ezrakim1323
@ezrakim1323 Жыл бұрын
If u don't want to remove all the previous contents of the file when u write in it, u can use append instead. The syntax is fptr = fopen("text.txt", "a");
@kartikpintu
@kartikpintu 9 ай бұрын
I was wondering about this. Thanks
@googlegurusai7005
@googlegurusai7005 7 ай бұрын
Thank u bro🎉
@christianstreby
@christianstreby 20 күн бұрын
Or you can do r+
@lamaspacos
@lamaspacos 9 ай бұрын
09:50 returns True True 😅
@limitess9539
@limitess9539 2 жыл бұрын
If you create a file via write mode, or append mode, try naming your file aux FILE *file1; file1=fopen("aux.txt","w"); the file with this name won't be created naming a file aux is forbidden in Windows, try creating a folder r text document and naming it aux... just some random stuff to spice things up
@countrysideshowyaigrock4689
@countrysideshowyaigrock4689 Жыл бұрын
I think the same with "con.txt"
@ardent630
@ardent630 Жыл бұрын
oh accha
@youssefamgad8199
@youssefamgad8199 11 ай бұрын
Tmrw is my programing final in engineering this just saved my life
@mrmikola4519
@mrmikola4519 10 күн бұрын
xddd🤣
@higgsboson6274
@higgsboson6274 2 жыл бұрын
finally programming in vs code 😍 and thanks for the video ma'am
@idc-ez7bo
@idc-ez7bo 10 ай бұрын
11:34 Answer : b) FILE* pointer
@rogue9433
@rogue9433 6 ай бұрын
the answer's B! Also, this vid's amazing; i got my programmin exam in a few hours, thank a bunch!
@amorycomedia3801
@amorycomedia3801 7 ай бұрын
it really helps me improve my knowledge about c programing
@anesp.a913
@anesp.a913 2 жыл бұрын
Option B is answer
@imrannazari8642
@imrannazari8642 Жыл бұрын
#include int main(){ FILE* fptr; fptr = fopen("1.txt","w"); char contant[1000]; fputs("C is a fun programming language ",fptr); fputs("And,I love using C language :)",fptr); fclose(fptr); fptr = fopen("1.txt","r"); while(fgets(contant, 1000, fptr)){ printf("%s",contant); } return 0; }
@kfirezer
@kfirezer Жыл бұрын
you forgot to close the file again after reopening
@countrysideshowyaigrock4689
@countrysideshowyaigrock4689 Жыл бұрын
@@kfirezer I think some data of file will be loss if he didn`t do that?
@kfirezer
@kfirezer Жыл бұрын
@@countrysideshowyaigrock4689 I don't think so, but it is a good practice since maybe you'll use unnecessary resources.
@jypee8070
@jypee8070 2 жыл бұрын
hii do you have tutorial on how to setup vscode
@shivamchakraborty9573
@shivamchakraborty9573 3 ай бұрын
Thank you so much for this, helped me in my project like an angel!!
@danutab3306
@danutab3306 2 жыл бұрын
wow, finaly i understood this !thank you a lot for this video👍👍👍👍
@amorycomedia3801
@amorycomedia3801 7 ай бұрын
your content helps me a lot
@lemichael2004
@lemichael2004 2 жыл бұрын
how to setting when you run code the visual code show the time executing those code? I saw you just click run code and there are time of executing code available there.
@panxel8615
@panxel8615 7 ай бұрын
Code Runner VSC Extension.
@devmalya2004
@devmalya2004 2 жыл бұрын
Thank you so much for this video. Much needed. 👍🏻
@ush6099
@ush6099 6 ай бұрын
Mam how to run the c code in vs code editor cause my code is not running and it shows 'gcc is not recognised '
@mohammadabdullahaalforhad1375
@mohammadabdullahaalforhad1375 11 ай бұрын
Your way of teching . easy to undestand
@MARK-hw8jm
@MARK-hw8jm 2 жыл бұрын
Option B
@Jeremyak
@Jeremyak 8 ай бұрын
Great videos thank you very much.
@bryanbalantes6486
@bryanbalantes6486 Жыл бұрын
/* * Create a new file in write mode * Write Content * C is a fun programming language. * And, I love using C language * Close the file * Again open the file in read mode and read the content of the file */ #include int main(){ FILE* fptr; fptr = fopen("newText.txt", "w"); fputs("C is a fun programming language.",fptr); fputs(" And, I love using C language",fptr); fclose(fptr); fptr = fopen("newText.txt", "r"); char content[1000]; if (fptr != NULL){ while (fgets(content, 1000, fptr)){ printf("%s", content); } }else{ printf("File Open Unsuccessful"); } fclose(fptr); return 0; }
@Bruhhn
@Bruhhn 10 ай бұрын
shouldn't the fclose() be inside if block, at its end. As in case of unsuccessful opening of file (execution of else statement) , fclose() doesn't make any sense. Please correct me if I'm wrong
@PankajSingh-ww5pl
@PankajSingh-ww5pl Жыл бұрын
Mine was 1000th like to the vid....😎😎 apart really helpful
@paypali2238
@paypali2238 2 жыл бұрын
B option
@Apekshakene
@Apekshakene Жыл бұрын
These. Video is really very helpful
@b7sh_b7sh
@b7sh_b7sh Жыл бұрын
amazing teacher
@JocularmarsAH
@JocularmarsAH Жыл бұрын
thank you soooo much madam
@PriyankaVerma-ec2kd
@PriyankaVerma-ec2kd 26 күн бұрын
Thankyou
@onic9623
@onic9623 Жыл бұрын
Option B : FILE* pointer; --------------------------------------------------------------------------------------------------------------- #include int main() { FILE* file; file = fopen("newFile.txt", "w"); fputs("C is a fun programming language ", file); fputs("And, I love using C language", file); fclose(file); file = fopen("newFile.txt", "r"); char content[1000]; while (fgets(content, 1000, file)); { printf("%s", content); } return 0; }
@shaziya9734
@shaziya9734 Жыл бұрын
Why doesnt this work for visual studio 2019. I feel there is something changed in syntax which needs to be modified . Can you please help me with it.
@ironmonkey1990
@ironmonkey1990 8 ай бұрын
Thank you!
@emilyboyle7240
@emilyboyle7240 Жыл бұрын
is there another we condition we can use for that, because that doesnt realy make sense in my head,,, that statement does not return true or false, it just stores the line into the array
@pradeep-codes
@pradeep-codes 9 ай бұрын
The fgets statement doesn't return true or false but it does return a non-Null pointer as it reads a line from the file and stores it in the 'content' array, which is evaluated as true in the loop's condition, causing the loop to continue. Once fgets reaches the end of the file, it returns a NULL pointer, which is evaluated as false in the loop's condition, causing the loop to terminate.
@nilamvohra9340
@nilamvohra9340 Жыл бұрын
Nice teaching
@b_01_aditidonode43
@b_01_aditidonode43 Жыл бұрын
quiz answer option B
@yasirhasan484
@yasirhasan484 2 жыл бұрын
How can we open a file in a "for loop and create different files for each size of arrays. For example: For () { file 1 for array[0] File 2 for array[1].….. }
@mahisflow1165
@mahisflow1165 2 жыл бұрын
Mam from where I can check this?
@racingfan372
@racingfan372 2 жыл бұрын
Quiz answer is B
@narsimhanarsimha5244
@narsimhanarsimha5244 Жыл бұрын
To declare file pointer we use FILE.pointer
@panxel8615
@panxel8615 7 ай бұрын
no..?
@HIMANSHUJSBH52QPSF
@HIMANSHUJSBH52QPSF 7 ай бұрын
Answer: B
@Teachingjob01
@Teachingjob01 Жыл бұрын
Without closing the file how it's run
@charlyoro521
@charlyoro521 Жыл бұрын
What do i need to do if it thinks that the file doesnt have any text?
@panxel8615
@panxel8615 7 ай бұрын
I dont know ur code so
@dinbandhujana1390
@dinbandhujana1390 2 жыл бұрын
FILE* pointer
@Vyom330
@Vyom330 11 ай бұрын
5:52
@mohammadabdullahaalforhad1375
@mohammadabdullahaalforhad1375 11 ай бұрын
quiz ans. b) FILE *Pointer;
@yadlaaravind811
@yadlaaravind811 Жыл бұрын
Answer:b
@niloykumarmohonta
@niloykumarmohonta 2 жыл бұрын
NO : Let me so you USE : Let me show you
@Titan_Design
@Titan_Design 2 жыл бұрын
I actually like the way she says so instead of show lol
@countrysideshowyaigrock4689
@countrysideshowyaigrock4689 Жыл бұрын
@@Titan_Design How about jero instead zero? I like her transcription too
@shubhamkumargupta7953
@shubhamkumargupta7953 8 ай бұрын
option b
@peterrepaso1293
@peterrepaso1293 Жыл бұрын
How to use a file when using a real program
@alaaanees9955
@alaaanees9955 Жыл бұрын
nice
@b7sh_b7sh
@b7sh_b7sh Жыл бұрын
programiz quiz : the ansewr is B
@wasswapeter3790
@wasswapeter3790 2 жыл бұрын
B
@LostInTheMysteriousWorld
@LostInTheMysteriousWorld 5 ай бұрын
Quiz Answer: B) FILE* fptr;
@LostInTheMysteriousWorld
@LostInTheMysteriousWorld 5 ай бұрын
Sorry answer would be B) FILE* pointer;
@azhanisyahputra9867
@azhanisyahputra9867 2 жыл бұрын
the girl who taught this is pretty
@nsfw_metaMorph21
@nsfw_metaMorph21 2 жыл бұрын
She is cute ,isn't she?
@nandishnandish7436
@nandishnandish7436 2 жыл бұрын
So...pretty
@Baka100
@Baka100 2 жыл бұрын
Simp ranmati
@kokoloko338
@kokoloko338 11 ай бұрын
@@Baka100simp for thinking a girl is pretty? no wonder yall are third world countries
@antoine2571
@antoine2571 7 ай бұрын
Programmers seeing a girl for the first time in months because they fell into programming spiral :
@formodapk
@formodapk 2 ай бұрын
hi
@LogXTX
@LogXTX Жыл бұрын
She's Nepali
@bryanbalantes6486
@bryanbalantes6486 Жыл бұрын
B. FILE* pointer;
@khushbhatt5378
@khushbhatt5378 Жыл бұрын
one complier is showw much better
@ayushkumarswain7334
@ayushkumarswain7334 2 жыл бұрын
why are you so cute?
@princesxnsai2196
@princesxnsai2196 Ай бұрын
Aukat mai
@shubhamsingh-bi7np
@shubhamsingh-bi7np 2 жыл бұрын
b
@SumEarth
@SumEarth Жыл бұрын
Always a Indian
@sandeepvarma8453
@sandeepvarma8453 8 ай бұрын
programming quiz: #include int main(){ FILE* fptr; fptr = fopen("newfile.txt","w"); fputs("c is afum programming language ",fptr); fputs("i love c language",fptr); fptr= fopen("newfile.txt","r"); char content[1000] if(fptr!=NULL){ fgets(content,1000,fptr); printf("%s",content); } else{ printf("file open is unsuccessfull"); } fclose(fptr); return 0; }
@janewaguthi4342
@janewaguthi4342 Жыл бұрын
A
@Aksar_Ojha
@Aksar_Ojha 9 ай бұрын
Worst explanation ever .
@imduckworth
@imduckworth 9 ай бұрын
#include #include // Include for exit() function int main() { FILE* fptr; char content[1000]; char userInput[1000]; // Open the file in write mode fptr = fopen("NewFile.txt", "w"); if (fptr == NULL) { printf("Error opening file. "); exit(1); } // Prompt the user to enter text printf("What do you want to add in NewFile.txt? "); fgets(userInput, sizeof(userInput), stdin); // Write user input to the file fputs(userInput, fptr); // Close the file fclose(fptr); // Open the file in read mode fptr = fopen("NewFile.txt", "r"); if (fptr == NULL) { printf("Error opening file. "); exit(1); } // Read and print the contents of the file printf("Contents of NewFile.txt: "); while (fgets(content, sizeof(content), fptr)) { printf("%s", content); } // Close the file fclose(fptr); return 0; }
@poornimaramkumar9165
@poornimaramkumar9165 6 ай бұрын
#include int main() { // Write C code here FILE* fptr; fptr=fopen("File.txt","w"); char content[1000]; fputs("C is a fun programming language",fptr); fputs("And I love C language",fptr); fptr=fopen("File.txt","r"); fgets(content,1000,fptr); fclose(fptr); return 0; } It shows the segmentation fault error in the online c programming
@b7sh_b7sh
@b7sh_b7sh Жыл бұрын
// Online C compiler to run C program online #include int main() { FILE* fptr; fptr = fopen("one piece.txt","r"); char content[1000]; fputs("i love one piece anime ",fptr); fputs("the most one that i love in one piece is lufy", fptr); fclose(fptr); fptr = fopen("one piece.txt","r"); while(fgets(content, 1000, fptr)){ printf("%s",content); } return 0; }
@countrysideshowyaigrock4689
@countrysideshowyaigrock4689 Жыл бұрын
#include int main() { FILE* fptr; fptr = fopen("newFile.txt", "w"); fputs("C is a fun programming language ", fptr); fputs("And, I love using C language", fptr); fclose(fptr); char content[1000]; fptr = fopen("newFile.txt", "r"); if (fptr != NULL) { while (fgets(content, 1000, fptr)) { printf("%s", content); } } else { printf("File Open Unsuccessful"); } fclose(fptr); return 0; }
@umehabiba5472
@umehabiba5472 2 жыл бұрын
Option B
@kirwanaericroberts4803
@kirwanaericroberts4803 2 жыл бұрын
B
@ardent630
@ardent630 Жыл бұрын
FILE *pointer
@JeanNepoMunezero
@JeanNepoMunezero 4 ай бұрын
B. FILE* pointer;
@suhailpasha698
@suhailpasha698 Жыл бұрын
b
@JeongWoonKim-i4j
@JeongWoonKim-i4j Жыл бұрын
#include int main() { FILE* fptr; fptr = fopen("newFile.txt", "w"); fputs("C is fun programming language ", fptr); fputs("And, I love using C programming", fptr); fclose(fptr); fptr = fopen("newFile.txt", "r"); char content[1000]; if (fptr != NULL) { while(fgets(content, 1000, fptr)) { printf("%s", fptr); } } else { printf("File open Unsuccessful"); } fclose(fptr); return 0; }
@PraveenPraveen-us3rp
@PraveenPraveen-us3rp Жыл бұрын
Option B
@adarsh70076
@adarsh70076 Жыл бұрын
B
@gowthamg1204
@gowthamg1204 Жыл бұрын
B
@rakesh1045
@rakesh1045 Жыл бұрын
B
@fateemahamosuro4788
@fateemahamosuro4788 10 ай бұрын
B
@kimsannmao5147
@kimsannmao5147 Ай бұрын
B
#30: Preprocesor and Macros | C Programming for Beginners
9:00
File Access Basics | C Programming Tutorial
24:05
Portfolio Courses
Рет қаралды 105 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
C_119 File Handling in C - part 1 | Introduction to Files
12:15
Jenny's Lectures CS IT
Рет қаралды 372 М.
#23 C Pointers | C Programming For Beginners
11:01
Programiz
Рет қаралды 157 М.
Reading and Writing Files in C, two ways (fopen vs. open)
7:07
Jacob Sorber
Рет қаралды 106 М.
C_131 C program to copy content of one file into another file | File Handling in C
14:09
Reading/Writing structs to files (aka Serialization)
14:41
CodeVault
Рет қаралды 77 М.
you will never ask about pointers again after watching this video
8:03