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.
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 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
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
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 .
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 .
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
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
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); }
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.
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. :))
We can simply write charac++ without else block.
Hey mera characters count galt a rha kya bta sakt k newline (
) b characters ,ma count ho ga?
@@farzanaashraf8136 yeah i know, that's just the way how i do my code neatly
@@marbles5590 Nice
but in your program it doesn't account for the '
' or aren't we supposed to include them
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);
}
But i guss it will take
also as a character but we don't want to count
as a character.
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
@@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
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
just add int len=ftell(fp); after the while loop it will give the length of file
Mam u r simply awesome, u made C easy and understanding, thank you so much
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😅
Mam your video's are so much help full to. TQ mam for helping us 🌟
Mam plzz try start any other language like Java, or python like this , coz your teaching style too good mama so
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 .
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 .
Hello Jenny, May you please make videos on Command Line Arguments too? Thank you and you are an awesome and cool TECH LADY!
Mam please make one small video to visual studio code (c programs setup).
Mam kal exam h aaj raat ko pointer ki video one shot video upload honi chahiye
Mazaa aa gayaa ma'am ji🙏
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);
}
Bro i want to just friendship with you for coding
Can you be my friend..
@@satyabrata2129 yeah why not😇
@@satyabrata2129 sid_sidharth_19
Id of instagram
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
Mam one doubt..that in this program how the cursor is incremented by 1 in while loop mam
Mam.total kitne tutorials hai..c..k????
Can you make video of string, array and char related concepts , how to play with this
we have't increased the file pointer but also how its taking next character ?
Delete,sort,word replace related programs mam in file handling
Mam please do the chapter text processing & pattern searching
Mam if possible then u teach us on an compiler extension...like as VS Code , Dev or anything. Which u like most ..
mam can you make a vedio on ...
1. write a program to find and replace a word in a File by another given word
How to delete a particular line in a file
Please tell a program for sudo code...please mam🙏🙏
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
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);
}
Without rewind() it also cam be possible.... ..
It's correct or not..
@@satyabrata2129 yes without rewind it can be done
@@satyabrata2129 this solution provided vinayak is incorrect
not correct
Mam please reply
I know nothing about coding and programming or algorithm
How to start I learning for beginner
Step to step
🙏🙏🙏
Mam please make video about how to get job after graduation
Bhai pata chal gya hoto mujhe bhi bata de ....
Mam please do important programs for drives
#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;
}
mam please can you explain how to print a specific line from a file (file handling)
Write a C program to replace vowels in a text file with character ‘x’
Big fan ma'am
Useful mam Thankyou
Mam.big fan from Kashmir....
how to sort a given file
Thank you very much mem.
Kl exam hai apki wishes chaiye
Beautiful
Thanks mam
wel done mam
Ma'am aaj tho rest karna dho plzz
🤣🤣🤣
THERE ARE MANY ADVERTİSEMENTS İT İS ANNOYİNG WHİLE I AM STUDYİNG
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
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);
}
Mem aap ko kya pdate ho
Ma'am please explain about python 🙏
Godess 🙏 tq for teaching it is easily understandable
Tower of Hanoi
Mam explain dynamic memory allocation
Hindi me praiyye na mam smjh me nhi aata h😢
she getting so cute
Mamm love you so much.....u r my crush mamm
i love you mdama i will die for you please accept my love ❤😘
😒😮💨😮💨🤥🤥😒
I am first
Im first
Mam do you have a sister 🥰
#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;
}
#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);
}
𝕋𝕙𝕒𝕟𝕜 𝕪𝕠𝕦 ❤ 𝕞𝕖𝕞