我读这个是为了做我的方法
我有一个文件:software_pluginInterface.di
我在这里声明:
extern (C): void performComputation(char lib[], char func[], void* ptr[], int varNum );
// lib and func will be used later
Run Code Online (Sandbox Code Playgroud)
然后我有相应的C文件:software_pluginInterface.c,我声明:
#include "stdio.h"
#include "string.h"
void performComputation(char lib[], char func[], void * v[], int varNum)
{
printf("there are %d variables \n", varNum);
}
Run Code Online (Sandbox Code Playgroud)
然后我称之为:
performComputation(A, B, V, to!int(v.count()/3));
Run Code Online (Sandbox Code Playgroud)
A,B是'\ 0'终止char arrarys V是一个带有6个元素的void指针数组
所以我希望输出如下:有2个变量
但我得到:有1557197040变量
我有64位操作系统,我使用编译它(如在另一个问题中)
gcc -c software_pluginInterface.c
dmd software.d software_pluginInterface.o
Run Code Online (Sandbox Code Playgroud)
然后我用:./ software来打电话给他们
PS:根据此页面,D int与C ints相同.
我提前道歉,这可能是一个非常愚蠢的问题,有一个显而易见的解决方案,它逃避了一个相当初学者的眼睛,或者它也可能已经在Stackoverflow中作为一个解决的问题,但我缺乏关于究竟是什么的知识寻找是阻止我实际找到答案.
我有一个字符串:
$s = FOO: < single blankspace> BAR <some whitespace character> some more text with whitespace that can span over multiple lines, i.e. has \n in them ;
#please excuse the lack of quotes, and large text describing the character in angular brackets, but in this example, but I have the string correctly defined, and in plase of <blankspace> I have the actual ASCII 32 character etc.
Run Code Online (Sandbox Code Playgroud)
现在我想以这种方式拆分$ s:
($instType, $inst, $trailing) = split(/\s*/, $s, 3);
#please note that …Run Code Online (Sandbox Code Playgroud)