Here's the question.
http://postimg.org/image/nmqrupznp/
And here's my program,
#include <stdio.h>
#include <string.h>
void encrypt (char *text,char *map);
void decrypt (char *text,char *map);
int main()
{
int a,b;
char c[]="abcdefghijklmnopqrstuvwxyz";
char d[]="thequickbrownfxjmpsvlazydg";
char *text;
char *map;
text=&c[0];
map=&d[0];
printf ("Encrypt press 1;Decrypt press 0.\n");
scanf ("%d",&b);
if (b!=0&&b!=1)
printf ("please enter 0 or 1.\n");
printf ("Encrypt press 1;Decrypt press 0.\n");
if (b==1)
encrypt (text,map);
else
decrypt (text,map);
return 0;
}
void encrypt(char *text,char *map)
{
int x=1,c;
char a[100];
printf ("Enter a string for encryption.\n");
scanf ("%s",a[100]);
c=strlen(a);
char *z;
z=&a[0];
while (x<=c)
{
if (*z==*text)
{strcpy (z,map);
printf ("%d",a[x]);
text=text+1;
z++;
}
else
printf ("error input.");
break;
}
}
void decrypt(char *text,char *map)
{
int x=1,c;
char a[100];
printf ("Enter a string for encryption.\n");
scanf ("%s",a[100]);
c=strlen(a);
char *z;
z=&a[0];
while (x<=c)
{
if (*z==*map)
{strcpy (z,text);
printf ("%d",a[x]);
text=text+1;
z++;
}
else
printf ("error input.");
break;
}
}
-------------------
Can you guys help me on this?
On which part did I do wrong?