#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Exclamation my output doesnt match


    PHP Code:
    [CODE]#include <stdio.h>
        #include <string.h>

        
    void encrypt(char *textchar *map);
        
    void decrypt(char *textchar *map);
        
    char string[100];

        
    int main()
        {
            
    char *cptr_text;
            
    char *cptr_map;

            
    char b[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
            
    char a[] = {'t','h','e','q','u','i','c','k','b','r','o','w','n','f','x','j','m','p','s','v','l','a','z','y','d','g'};

            
    cptr_text = &b[0];
            
    cptr_map = &a[0];

            
    encrypt(cptr_textcptr_map);
            
    decrypt(cptr_textcptr_map);

            return 
    0;
        }

        
    void encrypt(char *textchar *map)
        {

            
    int x 0;

            
    printf("Please enter the string: ");
            
    scanf("%s"string);

            for (
    0strlen(string); x++)
            {
            if(
    islower(string[x]))
            
    string[x]=map[string[x]-'a'];

            }

            
    printf("The Ciphertext is: %s\n"string);
        }

        
    void decrypt (char *textchar *map)
        {

                
    int x=0;
                for (
    0strlen(string); x++)
            {
            if(
    islower(string[x]))
            
    string[x]=text[string[x]-'t'];


            }
            
    printf("The Plaintext is: %s\n"string);

    }

    //Output:
    //Please enter a string: ilovecprogramming 
    //The ciphertext is "bwxauejpxcptnnbfc" 
    //The plaintext is "ilovecprogramming"[/CODE] 
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0
    Code:
    #include <stdio.h>
    #include <string.h>
    
    void encrypt(char *text, char *map);
    void decrypt(char *text, char *map);
    char string[100];
    
    int main()
    {
        char *cptr_text;
        char *cptr_map;
    
        char b[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        char a[] = {'t','h','e','q','u','i','c','k','b','r','o','w','n','f','x','j','m','p','s','v','l','a','z','y','d','g'};
    
        cptr_text = &b[0];
        cptr_map = &a[0];
    
        encrypt(cptr_text, cptr_map);
        decrypt(cptr_text, cptr_map);
    
        return 0;
    }
    
    void encrypt(char *text, char *map)
    {
    
        int x = 0;
    
        printf("Please enter the string: ");
        scanf("%s", string);
    
        for (x = 0; x < strlen(string); x++)
        {
        	    if(islower(string[x])){
        		    string[x]=map[string[x]-'a'];
    	            printf("%d %d\n", string[x], string[x] - 'a');		
    	    }
    
        }
        printf("The Ciphertext is: %s\n", string);
    }
    
    void decrypt (char *text, char *map)
    {
    	int x=0;   
    	for (x = 0; x < strlen(string); x++)
            {
        	        if(islower(string[x])){
        		        string[x]=text[string[x]-'t'];
                            printf("%d %d\n", string[x], string[x] - 't');
    		}
    	}
            printf("The Plaintext is: %s\n", string);
    }
    
    
    //Output:
    //Please enter the string: abc
    //116 19
    //104 7
    //101 4
    //The Ciphertext is: the
    //97 -19
    //-1 -117
    //86 -30
    //The Plaintext is: a�V

IMN logo majestic logo threadwatch logo seochat tools logo