I just want to make a couple notes/suggestions. The code you posted is likely to cause problems or create a fatal runtime error. You declare two pointers to memory, but do not initialize them to memory addresses that are known to be allocated and part of your program's address space. Leaving them uninitialized means they point to random memory addresses, which could hold other parts of your program, or could be illegal to use. When you strcpy into those addresses, you are asking for trouble.
I think it would be well worth your time to read up on strings and memory management in an introductory C book or tutorial. Pointers and memory management are the biggest initial hurdle most people face when learning C, and it's definitely worth getting a good understanding of it, or else those kinds of problems will continue to plague your code.
I also think many of the difficulties you're having in getting the simple function interface that you want come from the nature of the C language. Memory management is part of C programming. If your clients are writing C code, then it is natural to expect them to take on the responsibilities of memory management (i.e. passing in pre-allocated arrays, freeing a returned array, or copying the returned string into their own memory). Aside from very unusually complex approaches, like writing your own memory manager and/or garbage collector, there is no real way to shield your clients from this burden. The CVI developers do their best to make CVI libraries as simple to use as possible, and you'll notice that this still means most library functions that handle memory require the client to pass in a pre-allocated buffer. As long as your library functions are documented well and clearly state the caller's responsibilities, you should not feel bad about leaving some memory management work to your clients.
Good luck.
Mert A.
National Instruments
Message Edited by Mert A. on 02-09-2007 11:20 AM