Click here to Skip to main content
15,889,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 ;)
Posted
Comments
Richard MacCutchan 3-Jan-15 12:25pm    
You should always start by checking the value of argc. That will tell you how many parameters are set in the argv array. Remember also that argv[0] is a pointer to the full path of the executable program.

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...
 
Share this answer
 
hi,
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 !!
 
Share this answer
 
Comments
Maral Azizi 3-Jan-15 12:11pm    
I tried command line but it gave noting, it just goes to :

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;
}
there are only some few error:

-set_new_handler identifier "set_new_handler" is undefined

-strcmp Taking the address of an intrinsic function is not allowed.

and when I am trying to Addwatch argv[1] value is shows 69'E'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900