#Include Int Main : //C Code To Count Number of Words Spaces and White Characters
#Include Int Main : //C Code To Count Number of Words Spaces and White Characters
#include <stdio.h>
int main()
{
char str[100];//input string with size 100
scanf("%[^~]",&str);//scanf formatting
for(int i=0;str[i]!='\0';i++)
{
if(str[i] == ' ')
{
words++;
}
else if(str[i] == '\n')
{
newline++;
words++;//since with every next line new words start. corner case 1
}
else if(str[i] != ' ' && str[i] != '\n'){
characters++;
}
}
if(characters > 0)//Corner case 2,3.
{
words++;
newline++;
}
printf("Total number of words : %d\n",words);
printf("Total number of lines : %d\n",newline);
printf("Total number of characters : %d\n",characters);
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main(){
//file nane
//file pointers
FILE *fp,*fp1;
char ch;
fp=fopen(fileName,"r");
if(fp==NULL){
return -1;
fp1=fopen("temp.txt","w");
if(fp1==NULL){
return -1;
while((ch=fgetc(fp))!=EOF){
if(islower(ch)){
ch=ch-32;
putc(ch,fp1);
fclose(fp);
fclose(fp1);
rename("temp.txt","sample.txt");
remove("temp.txt");
fp=fopen(fileName,"r");
if(fp==NULL){
return -1;
printf("Content of file\n");
while((ch=getc(fp))!=EOF){
printf("%c",ch);
}
printf("\n");
fclose(fp);
return 0;
#include <stdio.h>
int main()
char filename[100], c;
scanf("%s", filename);
if (fptr1 == NULL)
exit(0);
}
printf("Enter the filename to open for writing \n");
scanf("%s", filename);
if (fptr2 == NULL)
exit(0);
c = fgetc(fptr1);
while (c != EOF)
fputc(c, fptr2);
c = fgetc(fptr1);
fclose(fptr1);
fclose(fptr2);
return 0;