C
Chris
Hi,
using DLLImport as follows :
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int scanf(string format, ref int s1);
then using :
int sum=0;
scanf("%d", ref sum);
Console.WriteLine("Using int = {0}", sum);
OK, this works
Now using a string ...
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int scanf(string format, ref string s1);
string strSum=" ";
scanf("%s", ref strSum);
==> NullReferenceException
Omitting 'ref' doesn't throw an exception but doesn't give me anything back
in 'strSum' of course.
Any ideas ?
Second question :
isn't there any way to import printf() using only 1 DllImport declaration
such as for example :
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int printf(string format, params object[] s2);
Unfortunately it does not work properly :-((
thnx
Chris
using DLLImport as follows :
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int scanf(string format, ref int s1);
then using :
int sum=0;
scanf("%d", ref sum);
Console.WriteLine("Using int = {0}", sum);
OK, this works
Now using a string ...
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int scanf(string format, ref string s1);
string strSum=" ";
scanf("%s", ref strSum);
==> NullReferenceException
Omitting 'ref' doesn't throw an exception but doesn't give me anything back
in 'strSum' of course.
Any ideas ?
Second question :
isn't there any way to import printf() using only 1 DllImport declaration
such as for example :
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]
public static extern int printf(string format, params object[] s2);
Unfortunately it does not work properly :-((
thnx
Chris