Thread: structure ...solution plz????

  1. #1
    Registered User
    Join Date
    Jun 2006

    structure ...solution plz????

    Hi ,

    I am having a structure,
    structure mine{
    char SPI[6];
    char authvalue[16];
    int client;

    Here I am putting the values for auth,SPI & client.
    I need to to send this structure to other pprogram.( I am using socket proigramming)
    auth value -1234567890123456
    client -1
    I am copying these values in to my above structure
    But ,,My structure is sending
    client =1

    how can I overcome this auth value problem..?

    any solution?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > 1234567890123456
    A 16 character string needs to be placed into a 16 char array very carefully (not strcpy)
    How did you pack and unpack this struct?
    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 cbastard's Avatar
    Join Date
    Jul 2005
    You may face some problem with the portability if there is difference in byte alignment of both the machines.
    Long time no C. I need to learn the language again.
    Help a man when he is in trouble and he will remember you when he is in trouble again.
    You learn in life when you lose.
    Complex problems have simple, easy to understand wrong answers.
    "A ship in the harbour is safe, but that's not what ships are built

  4. #4
    Registered User
    Join Date
    Jun 2006
    then how can I get correct values?

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Send each structure member one at a time and then the client can reassemble the struct on the receiving end.

    You also didn't answer Salem's question.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing Structure Pointers to Functions
    By samus250 in forum C Programming
    Replies: 15
    Last Post: 03-20-2008, 03:13 PM
  2. Replies: 13
    Last Post: 12-14-2007, 03:34 PM
  3. passing structure arrays to functions?
    By bem82 in forum C Programming
    Replies: 3
    Last Post: 10-30-2006, 06:17 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM