Thread: Doubt on function routine

  1. #1
    Registered User
    Join Date
    Apr 2019

    Doubt on function routine

    i have a function
    void SendData(sint32_t data)
    One problem i am seeing is i need to send data of max size of uint32_t and also a function requiring to transmit a data of sint32_t also. If i use the uint32_t to SendData it will exceed the size. How do I do, do i need to write separate function for each data type?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Maybe review your other threads on the same subject:
    MSB and LSB of the signed value
    Signed and Unsigned Variables
    Missing basics of signed and unsigned numbers (this was 3 years ago)

    Mostly, the data transmission functions like read()/write() or recv()/send() don't give a damn about sign or endianess.

    void SendData(void *data, size_t size)
    In your other code, you do
    sint32_t a;
    uint32_t b;
    SendData(&a, sizeof(a));
    SendData(&b, sizeof(b));
    To SendData(), it's just a simple block of memory of a given size.
    It neither needs to know, or cares to know what it actually represents.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 06-17-2019, 10:43 PM
  2. Function pointer doubt
    By Satya in forum C Programming
    Replies: 2
    Last Post: 07-04-2015, 10:17 PM
  3. Function-doubt
    By fluteofliar in forum C Programming
    Replies: 9
    Last Post: 06-07-2010, 08:17 AM
  4. Doubt on scanf function
    By vandrea in forum C Programming
    Replies: 2
    Last Post: 09-13-2009, 11:25 AM
  5. function adapted from assembly routine
    By curlious in forum C++ Programming
    Replies: 0
    Last Post: 11-18-2003, 06:30 PM

Tags for this Thread