structure ...solution plz????

This is a discussion on structure ...solution plz???? within the C Programming forums, part of the General Programming Boards category; Hi , I am having a structure, structure mine{ char SPI[6]; char authvalue[16]; int client; }; Here I am putting ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    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
    SPI=200
    client -1
    I am copying these values in to my above structure
    But ,,My structure is sending
    authvalue-1234567890123456200
    SPI=200
    client =1

    how can I overcome this auth value problem..?

    any solution?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User cbastard's Avatar
    Join Date
    Jul 2005
    Location
    India
    Posts
    167
    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
    for"

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

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    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, 02:34 PM
  3. passing structure arrays to functions?
    By bem82 in forum C Programming
    Replies: 3
    Last Post: 10-30-2006, 05:17 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    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

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