Answer to Question #333180 in C for lota

Question #333180

Write an algorithm and implement a program in C to read the data from a

file (called “test.txt”), transform the data according to the discussion in

“Introductory”, and afterwards, save in another file (called “final.txt”).


1
Expert's answer
2022-04-26T09:27:50-0400


#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//define funcion for transformation
void doTranform(char *str)
{
  //For example do evere lowercase to uppercae letter
  for(int i=0;i<strlen(str);i++)
    {
      str[i]=toupper(str[i]);
    }
}
int main(void) {
 FILE *finp=fopen("test.txt","r+");
  FILE *fout=fopen("final.txt","w+");
  char line[100];//each line save to this id
  //will read use getline functio
  while(fgets(line,100,finp))
    {
      doTranform(line);
      fputs(line,fout);//write to file
      
    }
  fclose(finp);
  fclose(fout);
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS