我在我的GTK程序中仍然有问题。为什么会出现分段错误?
当我点击编码(或解码)按钮,我得到错误信息:
分段错误
我认为这个问题是来自功能:ret
和encode
,但无法找到它。
//..
//gets the first argument(buf)
tx1=gtk_entry_get_text(GTK_ENTRY(entry));
//...
//gets the second argument(pass)
tx2=gtk_entry_get_text(GTK_ENTRY(entry));
//....
//signal to callback function encode when button clicked
g_signal_connect(but,"clicked",G_CALLBACK(encode(tx1,tx2)),NULL);
// ...
//convert const char* to char*
char* ret (const char *bd){
char *c = new char[12];
strcpy(c,bd);
return c;
}
//encode function
char encode(const char ebuf[],const char epass[]) {
//This is the complete function I wrote and I am still having the error.
char *buf=ret(ebuf);
char *pass=ret(epass);
}
什么是ebuf和EPASS的strlens?为什么不使用'std :: string'? – user93353
为什么不使用调试器? – kotlomoy
它看起来像我在GTK根据什么rodrigo说 – afr0ck