Write a function c aesarm that takes as input two argument
Write a function ( c aesar.m ) that takes as input two arguments: a string to encrypt and the key (shift value) , and outputs a single argument which is a string containing the Caesar cipher encryption of the given string using the given key. The key may be positive (right shift) or negative (left shift). Your function should force the input to be uppercase and you should delete spaces and punctuation 2 .
Solution
#include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 #define MAX 200
void encryption(char *string, int shift )
 {
    char crypt[MAX], a, dest[MAX];
    printf( \"\ Original string is : %s\ \", string);
     int k=0, i=0;
     while(*string)
      {
         if (!ispunct((unsigned char) *string) && !isspace(*string))
          {
                 dest[i++] = toupper(*string);
         }
         string++;
     }
        dest[i] = \'\\0\';
        printf( \"\  Reformatted string is : %s\", dest);
      while(dest[k] !=\'\\0\')
       {
                a = toupper(dest[k]); // can use tolower(dest[k]) also as your wish
              if(a != \' \')
               {
                   a += shift;
                 if(a > \'z\') a -=26;
                 {
                    crypt[k] = a;
                    k++;
                 }
              }
       }
                 crypt[k]=\'\\0\';
                 printf(\"\ Encrypted string is : %s\ \", crypt);
 }
 int main()
 {
      char instr[MAX];
      int shift;/* this is the Caesar encryption key */
     printf(\"\  Enter your string\ \");
      //scanf(\"%s\", instr); // scanf will not scant the string with spaces
      gets(instr);
      printf(\"\  Enter your Key : \");
      scanf(\"%d\", &shift);
      encryption(instr, shift);
 }
         

