lab12.c - #include #include Forward...

Info icon This preview shows pages 1–4. Sign up to view the full content.

#include <stdio.h> #include <ctype.h> // Forward Declarations char * encodeCaesar(char * src, char * dest); char * decodeCaesar(char * src, char * dest); char * encodeSubstitution(char * lcEncodingKey, char * src, char * dest); char * decodeSubstitution(char * lcEncodingKey, char * src, char * dest); int testEncodeDecode(char * p1, char * p2); int main(int argc, char * argv[]) { // Test strings to be encoded char src1[50] = "abcdwxyz"; char src2[50] = "My secret password is: l3t ME [email protected]!"; char src3[50] = "Ciphers are fun!"; // lowercase encoding key for substitution cipher char lcEncodingKey[] = "qwertyuiopasdfghjklzxcvbnm"; // buffers to hold encoded and decoded strings char encoded[50]; char decoded[50]; // ***************************************** // DO NOT CHANGE ANYTHING IN THIS FUNCTION!
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

// ***************************************** printf("Begin test with src1...\n"); // Encode the string in src1 using Caesar encoding, and print the result printf("Caesar encoding '%s' yields '%s'\n", src1, encodeCaesar(src1, encoded)); // Decode the encoded string and print the result. printf("Caesar decoding '%s' yields '%s'\n", encoded, decodeCaesar(encoded, decoded)); // Confirm that the decoded string matches the original if (testEncodeDecode(decoded, src1) != 0) { printf("Error: Caesar encode/decode src1 does not work properly!\n"); return 1; } printf("Successfully encoded/decoded src1 using Caesar cipher.\n\n"); printf("Begin test with src2...\n"); // Encode the string in src2 using Caesar encoding, and print the result printf("Caesar encoding '%s' yields '%s'\n", src2, encodeCaesar(src2, encoded)); // Decode the encoded string and print the result. printf("Caesar decoding '%s' yields '%s'\n",
Image of page 2
encoded, decodeCaesar(encoded, decoded)); // Confirm that the decoded string matches the original if (testEncodeDecode(decoded, src2) != 0) { printf("Error: Caesar encode/decode src2 does not work properly!\n"); return 1; } printf("Successfully encoded/decoded src2 using Caesar cipher.\n\n"); printf("Begin test with src3...\n");
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 4
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '15
  • DavidAdams
  • Character encoding, ASCII

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern