
Fri, 28 Sep 2001 08:20:08 +0200, Sven Eric Panitz
xs <- peekCString cxs ys <- peekCString cys erg <- return (xs++ys)
The last line can be written: let erg = xs++ys and you can also directly write (xs++ys) instead of erg below.
newCString erg
All OK, except that you leak memory. This string is allocated using malloc and should be freed using free when no longer needed (either C free or Haskell free).
//calling Haskell function test=cAppend("the world"," is my oyster");
//printing its result printf("%s\n", test);
And then: free(test); BTW, there is less boilerplate (no startupHaskell etc.) when the main program is in Haskell instead of C (of course sometimes this is not what we want). -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK