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

Rotational Decypher I have all the libraries I think I need, what it is that I\'

ID: 646002 • Letter: R

Question

Rotational Decypher

I have all the libraries I think I need,

what it is that I'm trying to write, is a code that will take arg[1] and decypher it by rotating the characters until a word that matches the dictionary from argv[2] is true. I want to put argv[1] into an array and the dictionary from argv[2] into an array so I can compare them. I don't really have a clue as to what I'm doing, I just know what I need to do and not sure on how to implent it. The for loop where i=-50; i<51 is because the codes we have to decypher will have a key between -50,50

#include <Stdio.h>
#include <rotUtlis.h>
#include <stdlib.h>
#include <ctype.h>
#include <strings.h>


int main(int argc, char *argv[]){

  
//read array

   FILE *fp;
   fp = fopen(argv[1], "r");
   File *pf;
   pf=fopen(argv[2], "r");
   char c;
   c=fgetc(fp)
   int n;
   int rotate(c, n);
   bool found;

//length of first string

   int size = strlen(const char *s);

//create array of size [size] using coded message, and create array of dictionary words.

   int array[size];
   int dictionary[];`

//store first string of characters into an array

   for(i=0; i<size; i++){
  
       array[i] = c;
       dictionary[i] = ;
   }

//rotate characters in string untill = dictionary word
   while(found!=true){
          
       found = true

       for(i=-50; i<51; i++){
           rotate(int, int);
              
       }
  
   }
  
  
//read first string
//rotate characters in string n times
//compare result with dictionary
//if match not found - repeat
//if match found - key = n

//ARRAY OF PRINTABLE CHARACTERS?

   return 0;
}

Explanation / Answer

#include /* required for file operations */ #include /* for clrscr */ #include /* for delay */ FILE *fr; /* declare the file pointer */ main() { int n; long elapsed_seconds; char line[80]; clrscr(); fr = fopen ("elapsed.dta", "rt"); /* open the file for reading */ /* elapsed.dta is the name of the file */ /* "rt" means open the file for reading text */ while(fgets(line, 80, fr) != NULL) { /* get a line, up to 80 chars from fr. done if NULL */ sscanf (line, "%ld", &elapsed_seconds); /* convert the string to a long int */ printf ("%ld ", elapsed_seconds); } fclose(fr); /* close the file prior to exiting the routine */ } /*of main*/