C_130 C Program to Count no of Lines in a Text File | File Handling in C

  Рет қаралды 73,794

Jenny's Lectures CS IT

Jenny's Lectures CS IT

Күн бұрын

Пікірлер: 94
@harispap5180
@harispap5180 2 жыл бұрын
Tomorrow I'm writing my exam in data structures in c language, Jenny really helped me understand merge sort...wish my luck guys, i hope you do well in your exams too.
@marbles5590
@marbles5590 2 жыл бұрын
For the assignment: #include #include int main() { FILE *fp = NULL; int count = 1, charac=0; char ch; fp = fopen("abc.txt", "r"); if(fp==NULL) { printf ("ERROR"); exit(1); } while((ch=fgetc(fp))!=EOF) { if(ch==' ') { count++; } else { charac++; } } fclose(fp); printf (" Count: %d ", count); printf ("Number of Characters: %d", charac); return 0; } The variable charac is for the number of characters mam. :))
@farzanaashraf8136
@farzanaashraf8136 2 жыл бұрын
We can simply write charac++ without else block.
@farzanaashraf8136
@farzanaashraf8136 2 жыл бұрын
Hey mera characters count galt a rha kya bta sakt k newline ( ) b characters ,ma count ho ga?
@marbles5590
@marbles5590 2 жыл бұрын
@@farzanaashraf8136 yeah i know, that's just the way how i do my code neatly
@farzanaashraf8136
@farzanaashraf8136 2 жыл бұрын
@@marbles5590 Nice
@millicentwamuru314
@millicentwamuru314 2 жыл бұрын
but in your program it doesn't account for the ' ' or aren't we supposed to include them
@hariparuchuru3858
@hariparuchuru3858 2 жыл бұрын
Program to count No of characters in file This program also counts new line character also. #include #include void main() { FILE *fp = NULL; char ch; int LineCount =1, charcount =0; fp = fopen("abc.txt","r"); if (fp == NULL) { printf(" NO FIlE"); exit(1); } while((ch = fgetc(fp))!= EOF) { charcount++; if(ch == ' ') { LineCount++; } } fclose(fp); printf("The LineCount and charcount is %d and %d", LineCount, charcount); }
@gouravchandel8107
@gouravchandel8107 2 жыл бұрын
But i guss it will take also as a character but we don't want to count as a character.
@hariparuchuru3858
@hariparuchuru3858 2 жыл бұрын
If you don't want to add new line Then make a if condition for character count also If(ch != ' ') Charcount++; Then you won't count new line
@ahmed.saa7
@ahmed.saa7 2 жыл бұрын
@@gouravchandel8107 you can use else statement because if statement will only run when there is so it won't count because at that time only if statement will run and in other cases else will run and it will count number of characters in file
@tejhimanshu
@tejhimanshu 2 жыл бұрын
correct for line count not for char count when 2 or 3 lines are empty, only ' ', then it will count that character also use charcount-LineCount for calculating characters
@naveen5285
@naveen5285 2 жыл бұрын
Mam u r simply awesome, u made C easy and understanding, thank you so much
@SSingh_here
@SSingh_here 3 ай бұрын
just add int len=ftell(fp); after the while loop it will give the length of file
@sahilmd178
@sahilmd178 Жыл бұрын
assignment: #include #include int main(){ FILE *fp=NULL; char character; int count=1; int ch=0; fp=fopen("countline.txt","r"); if(fp==NULL){ printf("Error in creating file"); exit(1); } while((character=fgetc(fp))!=EOF){ if(character==' '){ count++; } // } //If u want to count characters with out spaces else if(character!=' '){ ch++; } } printf("NO of lines:%d ",count); printf("No of characters:%d",ch); fclose(fp); return 0; }//hope this helped u😅
@jony-s5m
@jony-s5m 2 жыл бұрын
Mam your video's are so much help full to. TQ mam for helping us 🌟
@mohankonduru6301
@mohankonduru6301 2 жыл бұрын
Mam plzz try start any other language like Java, or python like this , coz your teaching style too good mama so
@pinki256
@pinki256 5 ай бұрын
mam please help me to prepare this program: Q. Write a program to copy all the contents of one file to another file that stores all lower-case alphabets into lower.txt upper-case alphabets into upper.txt digits into digit.txt and rest of characters into rest.txt .
@jaxonffmgamer3318
@jaxonffmgamer3318 5 ай бұрын
Mam please help me to prepare this program: Q. Write a program to copy all the contents of one file to another file that stores all the lower-case alphabets into lower.txt upper-case alphabets into upper.txt digits into digit.txt rest of characters into rest.txt .
@parisa9374
@parisa9374 2 жыл бұрын
Hello Jenny, May you please make videos on Command Line Arguments too? Thank you and you are an awesome and cool TECH LADY!
@divyanshbalodhi5642
@divyanshbalodhi5642 2 жыл бұрын
Mazaa aa gayaa ma'am ji🙏
@Ankit-vp7nt
@Ankit-vp7nt 2 жыл бұрын
Mam please make one small video to visual studio code (c programs setup).
@__SHRAVANIPACHUNURI
@__SHRAVANIPACHUNURI 2 жыл бұрын
Mam one doubt..that in this program how the cursor is incremented by 1 in while loop mam
@hardiksharma5574
@hardiksharma5574 Жыл бұрын
#include #include #include int main(int argc, char const *argv[]) { FILE *fp; fp = fopen("abc.txt", "r"); char ch; int count = 1; int k = 0; while ((ch = fgetc(fp)) != EOF) { if (ch == ' ') { count++; } else { k++; } } fclose(fp); printf("%d ", count); printf("%d ", k); return 0; }
@uniquegaming1487
@uniquegaming1487 2 жыл бұрын
I don't know what r u teaching in your videos 😂 But I'm just watching videos again and again Your explanation is going better day by day so Just Thanks
@devendradangare440
@devendradangare440 2 жыл бұрын
we have't increased the file pointer but also how its taking next character ?
@vinayakghodke9871
@vinayakghodke9871 2 жыл бұрын
for no of characters: #include #include void main() { FILE *fp=NULL; fp=fopen("abc.txt","r"); int count=1; char ch; char str[50]; if(fp==NULL) { printf("error"); exit(1); } // rewind(fp); while((ch=fgetc(fp))!=EOF) { if(ch==' ') { count++; } } rewind(fp); fseek(fp,0,SEEK_END); printf("No of characters=%d ",ftell(fp)); fclose(fp); printf("No of lines=%d",count); }
@satyabrata2129
@satyabrata2129 2 жыл бұрын
Without rewind() it also cam be possible.... .. It's correct or not..
@mrinaltyagi2206
@mrinaltyagi2206 2 жыл бұрын
@@satyabrata2129 yes without rewind it can be done
@mrinaltyagi2206
@mrinaltyagi2206 2 жыл бұрын
@@satyabrata2129 this solution provided vinayak is incorrect
@tejhimanshu
@tejhimanshu 2 жыл бұрын
not correct
@87shortz
@87shortz Жыл бұрын
Mam kal exam h aaj raat ko pointer ki video one shot video upload honi chahiye
@_master_op_
@_master_op_ 2 жыл бұрын
CODE for counting the characters : #include #include void main() { FILE *fp=NULL; char c; int n=0; fp=fopen("abc.txt","r"); if(fp==NULL) { printf("no file"); exit(1); } //while((c=fgetc(fp))!=EOF) for(c=fgetc(fp);c!=EOF;c=fgetc(fp)) { n++; } fclose(fp); printf("Nmber of characters are : %d ",n); }
@satyabrata2129
@satyabrata2129 2 жыл бұрын
Bro i want to just friendship with you for coding Can you be my friend..
@_master_op_
@_master_op_ 2 жыл бұрын
@@satyabrata2129 yeah why not😇
@_master_op_
@_master_op_ 2 жыл бұрын
@@satyabrata2129 sid_sidharth_19
@_master_op_
@_master_op_ 2 жыл бұрын
Id of instagram
@tejhimanshu
@tejhimanshu 2 жыл бұрын
correct for line count not for char count when 2 or 3 lines are empty, only ' ', then it will count that character also consider it also
@faisalwani8055
@faisalwani8055 2 жыл бұрын
Mam.big fan from Kashmir....
@AmarSingh-ur5wq
@AmarSingh-ur5wq 2 жыл бұрын
Can you make video of string, array and char related concepts , how to play with this
@Beyondimagination1
@Beyondimagination1 2 жыл бұрын
Mam if possible then u teach us on an compiler extension...like as VS Code , Dev or anything. Which u like most ..
@cinexstudio0
@cinexstudio0 6 ай бұрын
Write a C program to replace vowels in a text file with character ‘x’
@faisalwani8055
@faisalwani8055 2 жыл бұрын
Mam.total kitne tutorials hai..c..k????
@sriratnaforlife1132
@sriratnaforlife1132 2 жыл бұрын
Mam please reply I know nothing about coding and programming or algorithm How to start I learning for beginner Step to step 🙏🙏🙏
@rajudr3286
@rajudr3286 2 жыл бұрын
Delete,sort,word replace related programs mam in file handling
@r.k8895
@r.k8895 2 жыл бұрын
Thank you very much mem.
@greenhomemusic3196
@greenhomemusic3196 2 жыл бұрын
Please tell a program for sudo code...please mam🙏🙏
@saifali-zk6yp
@saifali-zk6yp 2 жыл бұрын
Big fan ma'am
@souravmete8809
@souravmete8809 2 жыл бұрын
mam can you make a vedio on ... 1. write a program to find and replace a word in a File by another given word
@sangeetharam1382
@sangeetharam1382 2 жыл бұрын
Useful mam Thankyou
@luckysgallery4938
@luckysgallery4938 2 жыл бұрын
mam please can you explain how to print a specific line from a file (file handling)
@Sindhu.M.V
@Sindhu.M.V 11 ай бұрын
Mam please do the chapter text processing & pattern searching
@mgjdb
@mgjdb 2 жыл бұрын
Mam please do important programs for drives
@nageshgour3148
@nageshgour3148 2 жыл бұрын
Mam please make video about how to get job after graduation
@vinaygupta8532
@vinaygupta8532 Жыл бұрын
Bhai pata chal gya hoto mujhe bhi bata de ....
@dineshkantineni6232
@dineshkantineni6232 2 жыл бұрын
How to delete a particular line in a file
@pkmcdry9586
@pkmcdry9586 2 жыл бұрын
Beautiful
@medasridhanya6246
@medasridhanya6246 2 жыл бұрын
Godess 🙏 tq for teaching it is easily understandable
@57samarthhatte82
@57samarthhatte82 2 жыл бұрын
wel done mam
@dineshkantineni6232
@dineshkantineni6232 2 жыл бұрын
how to sort a given file
@abdulrahimjalloh363
@abdulrahimjalloh363 Жыл бұрын
Thanks mam
@87shortz
@87shortz Жыл бұрын
Kl exam hai apki wishes chaiye
@kdnation5629
@kdnation5629 2 жыл бұрын
If you tech in hindi language then more people take advantage of your videos.. You know very well that most of the people of india doesn't know English..India you know very well also that we are not sons of english
@abdulrahimjalloh363
@abdulrahimjalloh363 Жыл бұрын
Assignment: Number of lines and characters: #include #include int main(void) { FILE *fp = NULL; int count = 1; // Initialize count to 1 for the first line char ch; fp = fopen("abc.txt", "r"); if (fp == NULL) { printf("Error, file does not exist "); exit(1); } while ((ch = fgetc(fp)) != EOF) { if (ch == ' ') { count++; } } fseek(fp,0,SEEK_END); printf("No of characters is: %d ",ftell(fp)); printf("No of lines are: %d ", count); fclose(fp); }
@santoshkumarmahanty2048
@santoshkumarmahanty2048 2 жыл бұрын
Mamm love you so much.....u r my crush mamm
@sivapavanchowdary3755
@sivapavanchowdary3755 2 жыл бұрын
Ma'am please explain about python 🙏
@schoollife1284
@schoollife1284 2 жыл бұрын
Ma'am aaj tho rest karna dho plzz
@_kucial_
@_kucial_ 2 жыл бұрын
🤣🤣🤣
@tunahankarali6917
@tunahankarali6917 Жыл бұрын
THERE ARE MANY ADVERTİSEMENTS İT İS ANNOYİNG WHİLE I AM STUDYİNG
@howtodo2322
@howtodo2322 2 жыл бұрын
she getting so cute
@jitendraprajapat1192
@jitendraprajapat1192 2 жыл бұрын
Mem aap ko kya pdate ho
@priyanshubisht8326
@priyanshubisht8326 2 жыл бұрын
Tower of Hanoi
@bhavyaandhavarapu8452
@bhavyaandhavarapu8452 2 жыл бұрын
Mam explain dynamic memory allocation
@Rahul-pz9oe
@Rahul-pz9oe Жыл бұрын
Hindi me praiyye na mam smjh me nhi aata h😢
@Hemanthrr7
@Hemanthrr7 2 жыл бұрын
i love you mdama i will die for you please accept my love ❤😘
@p.adityapatro8673
@p.adityapatro8673 2 жыл бұрын
I am first
@MARCO__NG
@MARCO__NG Ай бұрын
😒😮‍💨😮‍💨🤥🤥😒
@mohanmedmamman7900
@mohanmedmamman7900 2 жыл бұрын
Mam do you have a sister 🥰
@KRISHNA_VLOGS49
@KRISHNA_VLOGS49 2 жыл бұрын
Im first
@robertmaina4807
@robertmaina4807 Жыл бұрын
#include #include int main() { FILE *fp; int count = 1; int c; char ch; fp = fopen("abg.txt","r"); if(fp == NULL) { printf("Error opening file "); exit(1); } while((ch = fgetc(fp)) !=(EOF)) { if(ch == ' ') { count++; } } fseek(fp, 0, SEEK_END); c = ftell(fp); printf("The number of characters are %d ", c); fclose(fp); printf("The lines are %d ", count); return 0; }
@Antik-n1b
@Antik-n1b 5 ай бұрын
#include #include void main() { char ch; int count = 0; int k = 1; FILE *fp = NULL; fp = fopen("abc.txt", "r"); if (fp == NULL) { printf("Error"); exit(1); } while (!feof(fp)) { ch = fgetc(fp); if (ch == ' ') k = k + 1; if ((ch != ' ') && (ch != ' ')) count = count + 1; } fclose(fp); printf("No. of characters = %d ", count - 1); printf("No. of lines = %d", k); }
@md_mazharul_haque
@md_mazharul_haque 2 жыл бұрын
𝕋𝕙𝕒𝕟𝕜 𝕪𝕠𝕦 ❤ 𝕞𝕖𝕞
C_131 C program to copy content of one file into another file | File Handling in C
14:09
C_132 Introduction to Dynamic Memory Allocation in C  | SMA vs DMA
17:38
Jenny's Lectures CS IT
Рет қаралды 291 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
C_119 File Handling in C - part 1 | Introduction to Files
12:15
Jenny's Lectures CS IT
Рет қаралды 377 М.
C_69 C Program to Reverse a String | with strrev() and without strrev() function
24:51
If you're ambitious but lazy, please watch this video...
12:57
Mark Tilbury
Рет қаралды 442 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 115 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 4,3 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН