Help for compilation and type casting

This is a discussion on Help for compilation and type casting within the C Programming forums, part of the General Programming Boards category; hi everyone, I am working on a program that calls another function, the other function has some variables which unsigned ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    28

    Help for compilation and type casting

    hi everyone,

    I am working on a program that calls another function, the other
    function has some variables which unsigned char the
    function that I am working on has some temporary char arrays
    and it causing a lot of trouble specially when using fgets .

    I am passing function callled encrypt( unsigned char *plain, unsigned char *cipher ) and I am passing two char arrays, I see that they are different but How do I get around this situation ?



    Code:
    code
    
    void CipherText(FILE *infile, FILE *outfile  )
    {
          int count = 0;
          int i;
          ByteType plain[Max + 1];
          ByteType cipher[Max + 1];
          char str [Max];
          ByteType *non_alpha_str;
    
          /* Read strings one by one from infile */
        while (fgets (str, Max, infile) != NULL)
        {
           /* Convert each string to one without non-alpha characters */
            non_alpha_str = get_alpha_str (str);
    
             for ( i = 0 ; i < Max; i++)
    	     {
    	        /* if characters read are 8, then we start processing */
                 if (count % 8 == 0)
    	         { 
    	          /*copy the non_alpha_charcter to temporary array for procesing */
                               /*copy the non_alpha_charcter to temporary array for procesing */
                      cipher [0] = non_alpha_str[ i  ];
                      cipher [1] = non_alpha_str[ i + 1 ];
                      cipher [2] = non_alpha_str[ i + 2 ];
                      cipher [3] = non_alpha_str[ i + 3 ];
                      cipher [4] = non_alpha_str[ i + 4 ];
                      cipher [5] = non_alpha_str[ i + 5 ];
                      cipher [6] = non_alpha_str[ i + 6 ];
                      cipher [7] = non_alpha_str[ i + 7 ];
                      cipher [8] = non_alpha_str[ i + 8 ];
                      cipher [9] = '\0';
                 /********** this function has 2 Bytetype rgumsents****/
                      Decrypt (cipher, plain );    ---
                      /* for test purposes */
                      printf("%c", plain );
    
                      /* write it to output file */
                      if (fputs (plain, outfile) == EOF)
                      {
                         printf("Error while writing %s\n", plain);
                      }
    
                      fputs (plain, outfile);
                      count = 0;
                      
                   }                   
                 count++;       
    	     }
    
               
    	  }
                   
    
    }

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    I do not really understand the question.

    >Decrypt (cipher, plain );

    Note that cipher and plain are arrays of ByteType's. Is Decrypt expecting arrays?

    Also note that you haven't allocated memory for non_alpha_str.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    28

    about casting problems

    Hi everyone,

    the plain and cipher are strings of chars that are passed to decrypt function for decryption, the decleaaration of decrypt function is as
    follows:

    Decrypt ( ByteType *x, ByteType *y);

    I am having too many warning from the compiler, I think because
    of the datatype difference. I was asking if there is a way to get around this situation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advantages of c++ type casting over c type casting
    By kaibalya2008 in forum C++ Programming
    Replies: 10
    Last Post: 05-05-2009, 12:09 PM
  2. type casting void *
    By Alexpo in forum C Programming
    Replies: 5
    Last Post: 06-23-2008, 04:05 AM
  3. What dose this type casting mean??
    By zhoufanking in forum C Programming
    Replies: 4
    Last Post: 06-11-2008, 07:09 AM
  4. Replies: 0
    Last Post: 03-20-2008, 08:59 AM
  5. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21