Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

usind function or loops how to encript input textfile for example score.txt Firs

ID: 3537910 • Letter: U

Question

usind function or loops

how to encript

input textfile for example score.txt

  First      Last    score  

     A            B     500    

     C            E     600    

     E           F     450  

     G            H     560    

     I            J    656    

     K           L     390

  

One character at a time should be read from the source file and then written to the destination file in encrypted form. The encrypted character should be the original character but with 50 ADDED to its ASCII code value.

outputfile score.enc


Explanation / Answer

#include #include using namespace std; int main() { //datatype for storing the scaned charecter char scannedcharecter; //filepointers for taking input inputfp and filepointer //outputfp to giveout output FILE *inputfp,*outputfp; //opening a file for reading and giving it to inputfp with read permissons inputfp = fopen("score.txt", "r"); //opening a file for writing and giving it to outputfp with write permissons outputfp = fopen("score.enc", "w"); //while loop for scannig charecter by charecter from the file and //break at the end of the file while (fscanf(inputfp, "%c", &scannedcharecter) != EOF) { //adding 50 to asci value for generating required asci value and printing its //symbol corresponding to that asci value in to the file fprintf(outputfp, "%c",int(scannedcharecter)+50); } //closing both the files fclose(inputfp); fclose(outputfp); return 0; }