c#用c++头文件

zzwwb1 2009-10-13 03:46:44
有一c++头文件,现在想把它直接在c#中的Form1.cs里使用,不想先编译成dll再调用
请各位高手帮我转换一下,不胜感激!!

typedef struct word
{
long high;
long low;
float sig;
word *next;
}*Word;

#define MAX_WORD_LEN_E_K 20

typedef struct keyword
{
char word[MAX_WORD_LEN_E_K];
int weight;
keyword *next;
}*Keyword;

typedef struct forbidword
{
char word[MAX_WORD_LEN_E_K];
forbidword* next;
}*Forbidword;
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyerwing 2009-10-13
  • 打赏
  • 举报
回复
Forbidword forbid_dic_head=new Forbidword();//在C井中类就是引用类型
forbid_dic_head.next=null;
zzwwb1 2009-10-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 flyerwing 的回复:]
public static const int MAX_WORD_LEN_E_K=20

public class keyword
{
    public char[]word=new char[MAX_WORD_LEN_E_K];
///public string word;//其实这里可以改成string类型那个常量基本没用了!
    public int weight;
    public keyword next;
}
public class forbidword
{
    public char[]word=new char[MAX_WORD_LEN_E_K];
///public string word;//其实这里可以改成string类型那个常量基本没用了!
    public forbidword next;
}

[/Quote]

再次请教
Forbidword forbid_dic_head=(Forbidword)malloc(sizeof(struct forbidword));
forbic_dic_head->next=NULL;
怎么在c#中实现?
flyerwing 2009-10-13
  • 打赏
  • 举报
回复

public static const int MAX_WORD_LEN_E_K=20

public class keyword
{
public char[]word=new char[MAX_WORD_LEN_E_K];
///public string word;//其实这里可以改成string类型那个常量基本没用了!
public int weight;
public keyword next;
}
public class forbidword
{
public char[]word=new char[MAX_WORD_LEN_E_K];
///public string word;//其实这里可以改成string类型那个常量基本没用了!
public forbidword next;
}
zzwwb1 2009-10-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 flyerwing 的回复:]
public class word
{
    public long high;
    public long low;
    public float sig;
    public word next;
}
public const int MAX_WORD_LEN_E_K=20

public class keyword
{
    char word[MAX_WORD_LEN_E_K];
    int weight;
    keyword next;
}
public class forbidword
{
    char word[MAX_WORD_LEN_E_K];
    forbidword next;
}
全部改成类类型就好了!


[/Quote]

不行啊!
两个char word[MAX_WORD_LEN_E_K]报错
flyerwing 2009-10-13
  • 打赏
  • 举报
回复
public class word
{
public long high;
public long low;
public float sig;
public word next;
}
public const int MAX_WORD_LEN_E_K=20

public class keyword
{
char word[MAX_WORD_LEN_E_K];
int weight;
keyword next;
}
public class forbidword
{
char word[MAX_WORD_LEN_E_K];
forbidword next;
}
全部改成类类型就好了!

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧