Monday, September 15, 2014

Decrypting a message program

Feel free to use it, modify it or anything.
Try using the input

y!sr@xo#dt$pa%or^ko*vb(da&ql

You'll get the output laboratory
I've wrote in the comments what each function does. According to that, modify it to make a suitable input


#include <stdio.h>
#include <string.h>
char string[50],t;
int l,k;
main()
{
int i,j;
  
  gets(string);
   printf(" string is %s\n",string);
    l=strlen(string);
    k=l;
    letsreverse();
}
letsreverse() //function reverses a string
{
    
int i=0,j,q;
char *ptr;
ptr=string; 
q=l;
q--;
for(i=0;i<=(l/2)-1;i++)
  {
 t=*(ptr+i);
 *(ptr+i)= *(ptr+q);
 *(ptr+q)=t;
 q--;
 }
 printf("Reverse string is %s\n",string);
 wedontlikejunk();

}
wedontlikejunk()     // kills off junk
 {
    int i=0,z,c=0,x;
    char clean[20];
    for(x=0;x<k;x++)
    {
         if(string[c] >= 'a' && string[c] <= 'z')
         {
         clean[i]=string[c];
         i++;
         }
         c++;
         
    }
    clean[i]='\0';
    printf("semi string is %s\n",clean);
    for(i=0;clean[i]!='\0';i++)
    string[i]=clean[i];
    string[++i]='\0';
    letskillsomeletters();
}
letskillsomeletters()     //kills alternate letters
{
    int i=0,z;
    char final[20];
    for(z=(10%10);z<k;z++)
    {
        final[i]=string[z];
        i++;
        z++;
        
    
    }
    printf("Final string is %s\n",final);
}

No comments:

Post a Comment