Thread: Trouble properly using buffers for function

  1. #1
    Registered User
    Join Date
    Jul 2018
    Posts
    5

    Trouble properly using buffers for function

    Here is the function I am trying to run:

    Code:
    int encrypt(
    unsigned char *cipher, unsigned long long *cipherlen,
    const unsigned char *plaintext, unsigned long long plaintextlen,
    const unsigned char *data, unsigned long long datalen,
    const unsigned char *sec,
    const unsigned char *public,
    const unsigned char *key);


    Here is my attempt:
    Code:
    #define BUFFER_SIZE  16    
    
    
    const unsigned char nonce[] = {00, 01, 02, 03, 04, 05, 06, 07, 0x08}; 
    const unsigned char key[] = {00, 01, 02, 03, 04, 05, 06, 07, 0x08,}; 
    const unsigned char ad[] = {00, 01, 02, 03}; 
        
    unsigned char buffer[BUFFER_SIZE + 1];                                                                                               
    
    
    int main(void)                                                                  
    {                                                                               
                                                        
        int encrypt(
        unsigned char buffer, sizeof buffer, 
        NULL, NULL, 
        const unsigned char data, sizeof data, 
        NULL, 
        const unsigned char public, 
        const unsigned char key);
        
            for(int i = 0; i < sizeof buffer; ++i) {
            printf("%02x", buffer[i]);}; 
        
    }
    The error flags 'expected identifier before sizeof' and 'expected ',' or '...' before sizeof '
    Any suggestions?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,631
    Yes, you should remove all the types from your attempt to call the encrypt() function.

    Do you see types in your printf call?
    Make it like that, only use variables and constants.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2018
    Posts
    5
    Trouble properly using buffers for function-code_error-png

    When I remove the types I get a different error now haha

  4. #4
    Registered User
    Join Date
    Jul 2018
    Posts
    5
    Fixed it!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble properly using buffers for function
    By swaroop4003 in forum C Programming
    Replies: 3
    Last Post: 07-03-2018, 09:48 AM
  2. Function not behaving properly
    By Moksha in forum C Programming
    Replies: 9
    Last Post: 01-19-2017, 01:50 PM
  3. How to properly use a function?
    By Who in forum C Programming
    Replies: 2
    Last Post: 02-01-2013, 03:25 AM
  4. advise on how to properly use pow function
    By libchk in forum C Programming
    Replies: 12
    Last Post: 08-31-2011, 12:50 AM
  5. How to properly use a C function?
    By John_L in forum C Programming
    Replies: 4
    Last Post: 05-30-2008, 02:01 AM

Tags for this Thread