int GetData(unsigned char* aBuffer);

This is a discussion on int GetData(unsigned char* aBuffer); within the C Programming forums, part of the General Programming Boards category; The following function is used to get some data from an external source (whatever is this source) and store them ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    int GetData(unsigned char* aBuffer);

    The following function is used to get some data from an external source (whatever is this source) and store them into the provided buffer.


    int GetData(unsigned char* aBuffer);



    Why is this function “dangerous”? How would you improve it so that it is not dangerous? (Hint: the question is not about the return value or the details of how the data is received).

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    buffer overrun
    add buffer length as a parameter
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    typedef

    thanx for that

    another question , is the following sytax correct ?

    typedef int myfunc(void*) myDefinedFunc();

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    I don't think so...
    this syntax resembles some definition of the pointer to the function, but where is the * indication that?

    And you cannot define type "function" only "pointer to function" is possible
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    > another question , is the following sytax correct ?
    > typedef int myfunc(void*) myDefinedFunc();
    Type it into a C program and compile it to find out.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By aruna1 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2008, 11:28 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 06:20 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

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