无法读取内存错误 [英] Unable to read memory Error

查看:167
本文介绍了无法读取内存错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我试图在vs 2013中的控制台应用程序中运行此代码,但是当我运行代码时出现以下错误:

-argv [1] 0x00000000 <空> char *



<无法=读=记忆=>



这是主函数代码:

int main(int argc,char ** argv)

{

set_new_handler(memory_err);

// cout<< 你好......<< argv [0]<< '\ n';;



if(strcmp(argv [1],lit)== 0){

/ /规则

TransPar par;



get_args(par,argc,argv); //得到论点

gen_rules(par); //生成规则(真的,只是交易)

}



else if(strcmp(argv [1],seq)= = 0){

//对于序列

SeqPar par;



get_args(par,argc,argv ); //得到论点

gen_seq(par); //生成序列

}



else if(strcmp(argv [1],tax)== 0){

//对于具有分类法的规则

TaxPar par;



get_args(par,argc,argv); //得到论点

gen_taxrules(par); //生成规则(真的,只是交易)

}



else if(strcmp(argv [1], - version) == 0){

print_version();

返回0;

}



else {

cerr<< 合成数据生成,

print_version();

cerr<< 用法:<< argv [0]<< lit | tax | seq [options] \ n;

cerr<< << argv [0]

<< lit | tax | seq -help更详细的选项列表\ n;

返回1;

}



返回0;

}



另外我应该提到源代码是为Unix构建的,但我修改了它以便运行获胜。

感谢先进的任何帮助或建议;)

Hi there
I am trying to run this code in console app in vs 2013 but when I run the code give following error:
-argv[1] 0x00000000 <null> char *

<unable to="" read="" memory="">

this is the main function code:
int main(int argc, char **argv)
{
set_new_handler(memory_err);
// cout << "Hello there..." << argv[ 0 ] << '\n';;

if (strcmp(argv[1], "lit") == 0) {
// For Rules
TransPar par;

get_args(par, argc, argv); // get arguments
gen_rules(par); // generate rules (really, just transactions)
}

else if (strcmp(argv[1], "seq") == 0) {
// For Sequences
SeqPar par;

get_args(par, argc, argv); // get arguments
gen_seq(par); // generate sequences
}

else if (strcmp(argv[1], "tax") == 0) {
// For Rules with Taxonomies
TaxPar par;

get_args(par, argc, argv); // get arguments
gen_taxrules(par); // generate rules (really, just transactions)
}

else if (strcmp(argv[1], "-version") == 0) {
print_version();
return 0;
}

else {
cerr << "Synthetic Data Generation, ";
print_version();
cerr << "Usage: " << argv[0] << " lit|tax|seq [options]\n";
cerr << " " << argv[0]
<< " lit|tax|seq -help For more detailed list of options\n";
return 1;
}

return 0;
}

Also I should mentioned the source code was built for Unix but I modified it for runing to win.
Thanks in advanced for any help or suggestion ;)

推荐答案

使用调试器。

main 函数的第一行放置一个断点,然后逐步查看每行执行前的数据。



猜测, argv 只指向一个字符串,后跟一个空值而不是你期望的两个。我通过检查 argc 来启动我的代码,以确保我有足够的数据,我自己...
Use the debugger.
Put a breakpoint on the first line of the main function and step through looking at the data before each line executes.

At a guess, argv only points at one single string, followed by a null value rather than the two you are expecting. I'd start my code by checking argc to make sure I had enough data, myself...


hi,

检查当你执行这段代码时,你是否传递了一个命令行参数?

因为在这段代码中,在main函数中,正在使用argv数组,它可能是丢失,所以它的抱怨。



在Visual Studio中,您可以在项目属性中添加参数。右键单击正在运行的项目,选择属性。在调试选项卡中,有一个命令行参数的输入框。在那里输入。



希望这有帮助!!

check that when you are executing this code, are you passing a command line argument ?
because in this code, inside the main function, the argv array is being used and it might be missing so its complaining.

In Visual Studio, you can add arguments in the Project Properties. Right click the project that is running, select Properties. In the Debug tab, there is a input box for Command Line Arguments. Enter them there.

hope this helps !!


这篇关于无法读取内存错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆