Thread: Passing pointer to struct through mailslots, memory allocation?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    24

    Passing pointer to struct through mailslots, memory allocation?

    I'm using mailslots to pass structs between programs, or more precisely pointers to those structs. It is "working" as its passing something, but I'm unable to print out anything from the structs on the receiving program. Do I have to do anything with memory allocation or am I missing something else?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Each program has a separate virtual address space.
    So a pointer to data in one program is meaningless to any other program.

    You need to pass actual data.
    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
    Apr 2010
    Posts
    24
    How do I accomplish this when WriteFile wants a pointer?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Is this different than any other time you write out data? If you had
    Code:
    char big_pile_of_data[1024];
    how would you use WriteFile to any file?

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    I think WriteFile would handle that big_pile_of_data just fine.

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Worked around it, just sent all the data separately.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 02:24 PM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  5. Passing a pointer to a struct
    By Natase in forum C Programming
    Replies: 2
    Last Post: 10-02-2001, 10:29 AM

Tags for this Thread