The goal of my assignment is to create a program that takes a string of words and encodes or decodes the string using a simple substitution cypher.
I've gotten a decent amount done but I am stuck at the part where I actually have to encrypt and decrypt using the offset that the user has input.
This is what I have, can anybody lend a hand?

include <stdio.h>
int main () {
#include <stdio.h>

int main () {


   char alpha[26] = "abcdefghijklmnop";
   char ALPHA[26] = "ABCDEFGHIJKLMNOP";
   char*encrypt(char*str,int offset);
   char*decrypt(char*str,int offset);

   int option;
   int offset;
   char str;


  char toencode(int alpha, int ALPHA);
  char todecode(int alpha, int ALPHA);

   printf("Select an option.\n");
   printf("1. Encrypt File\n");
   printf("2. Decrypt File\n");
   scanf("%d",&option);



   if(option == 1)
   printf("Encrypting\n");
   else if(option == 2)
   printf("Decrypting\n");
   else{
   printf("invalid entry\n");
   return 0;
   }


   printf("Please enter a number for the offset.");
   scanf("%d",&offset);

   while(1)
   {
   printf("Type entry to encrypt.\n");
   scanf("%s", &str);




return 0;
}   

Line 43: you ask the user for a string but the variable str is only a single character not a string (an array of char)

Your 2 arrays alpha and ALPHA seem unlikely, at this stage to be of any use.

Your encrypt function just needs to read everry letter in the string and replace it with another letter offset places down the alphabet. You could do this as modulo arithmetic, convert the letter to an index into the alphabet, add the offset in modulo 26 arithmatic.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.