anyway you realy make me open that c damn stupid book and read it ok i ve change it but still i have a problem to solve..
CODE
#include <stdio.h>
#include <string.h>
#include <conio.h>
char text[256];
int m,k,c,men;
/*Encrypt*/
void cez(char *Text)
{
printf("%s\n", "give me the text");
gets(Text);
printf("%s\n", "give me the key ");
scanf("%d", &k);
for(m = 0; m < strlen(text); ++m)
{
c = text[m] + k;
if(c > 256) c -= 256;
Text[m] = c;
}
}
/*Decrypt*/
void desh(char *Text)
{
printf("%s\n", "give me the decoding key ");
scanf("%d", &k);
for(m = 0; m < strlen(text); ++m)
{
c = Text[m] - k;
if(c < 256) c+=256;
Text[m] = c;
}
}
int main()
{
cez(text);
printf("%s\n", text);
desh(text);
printf("%s\n", text);
_getch();
return 0;
}
this is the code i manage to convert from pascal to c now how can i put a simple meny ,,,
cause when i put a menu with if it doesnt work ...well i m not sure that i do this menu right...
CODE
#include <stdio.h>
#include <string.h>
#include <conio.h>
char text[256];
int m,k,c,men,x;
print("1-encryption 2-decryption")
scan("%d"&x);
if x=1 do
/*Encrypt*/
void cez(char *Text)
{
printf("%s\n", "give text");
gets(Text);
printf("%s\n", "give me the key ");
scanf("%d", &k);
for(m = 0; m < strlen(text); ++m)
{
c = text[m] + k;
if(c > 256) c -= 256;
Text[m] = c;
}
}
/*Decrypt*/
else
void desh(char *Text)
{
printf("%s\n", "give me the decoding key ");
scanf("%d", &k);
for(m = 0; m < strlen(text); ++m)
{
c = Text[m] - k;
if(c < 256) c+=256;
Text[m] = c;
}
}
int main()
{
cez(text);
printf("%s\n", text);
desh(text);
printf("%s\n", text);
_getch();
return 0;
}
and the second problem of this code is that if i try to encrypt the letter o for example with a key 20 it doesnt show normal result whitch was i so i have a problem with the aski coding probably or something with that cause somehow it doesnt fit the english alphabet ..;(((
This post has been edited by biskot188: 22 Nov, 2008 - 01:52 AM