hi, i could use a little help today. I'm trying to make a program that will take a string input and according to a key edit each letter by moving it over in the alphabet with a wrap-around and output it. So right now the compiler errors i'm getting right now are
42:2 error:invalid operands to binary * (have 'int' and 'char *')
44:2 expected ';' before 'if'
51:1 expected declaration or statement at end of input
so i've been having trouble cause i'm just trying to use the function to edit the array with pointers and the array is characters so i don't know what i'm doing wrong. Any help would be greatly appreciated, thanks!
Code:
/* Caesar Cipher Project
Input a message and a shift amount
then prints out the encrypted message
Programmer:Derek Roncal
Date:10/12/11
*/
#include<stdio.h>
#include<string.h>
void letter_switcher(char a[], int b);
int main(void)
{
int k;
char input_buffer[81];
printf("Enter message to be encrypted:");
fgets(input_buffer, 80, stdin);
printf("Enter shift amount (1-15):");
scanf("%d", &k);
letter_switcher(input_buffer,k);
printf("%s",input_buffer);
return 0;
}
void letter_switcher(c a[],int b)
{ int i;
char*p;
p=a;
char code;
for(p=0; *p !='\0'; p++)
{ if((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z'))
{
code=*p
*p=((code-'A')+ b) % 26 + 'A'
if((*p >= 'a' && *p <= 'a')
{
code=*p;
*p=((code-'A')+ b) % 26 + 'A';
}
}
}