Thread: Pssing string to function in C

  1. #1
    Registered User
    Join Date
    Aug 2015
    Posts
    21

    Pssing string to function in C

    Good morning,

    I have a program made in VB and delphi that calls a C dll function which must handle a string.

    So, the function is more or less like this:

    Code:
    int32 function1(double p1, char *path)
    My problem is that it seems that when I use the variable path inside function1 I get one character only... So, if I pass for instance "c:\myfolder" I get "c". Must I define some other char to get path full value? Like:

    Code:
    char temp[50] = path;
    ?

    Can someone help me out here?

    Regards,

    JKepler

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Have you considered that what you're getting in the C function is a pointer to a UNICODE string?

    Use a loop to print a few extra bytes, and see if you see
    c\0:\0m\0y\0 etc

    If so, then perhaps
    int32 function1(double p1, wchar_t *path)
    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: 3
    Last Post: 01-15-2012, 06:09 AM
  2. Replies: 5
    Last Post: 10-24-2011, 12:35 PM
  3. Replies: 2
    Last Post: 05-19-2008, 10:42 PM
  4. Replies: 9
    Last Post: 04-16-2007, 03:02 PM
  5. Replies: 4
    Last Post: 01-22-2002, 11:13 PM

Tags for this Thread