josephdts
asked on
Parameters in C++/CLI
I need to pass parameters in the C++/CLI Console application like :Input File, Output File, Log File location. I would like to do it using array<String^>^args = Environment::GetCommandLin eArgs();
However, nothing is being passed from the console. There are a number of code examples in msdn, but they do not show how to input the arguments from the console. For example:
int main()
{
array<String^>^args = Environment::GetCommandLin eArgs();
const int tabSize = 4;
String^ usageText = "Usage: INSERTTABS inputfile.txt outputfile.txt";
StreamWriter^ writer = nullptr;
if ( args->Length < 3 )
{
Console::WriteLine( usageText );
return 1;
}
try
{
// Attempt to open output file.
writer = gcnew StreamWriter( args[ 2 ] );
// Redirect standard output from the console to the output file.
Console::SetOut( writer );
// Redirect standard input from the console to the input file.
Console::SetIn( gcnew StreamReader( args[ 1 ] ) );
}
However, nothing is being passed from the console. There are a number of code examples in msdn, but they do not show how to input the arguments from the console. For example:
int main()
{
array<String^>^args = Environment::GetCommandLin
const int tabSize = 4;
String^ usageText = "Usage: INSERTTABS inputfile.txt outputfile.txt";
StreamWriter^ writer = nullptr;
if ( args->Length < 3 )
{
Console::WriteLine( usageText );
return 1;
}
try
{
// Attempt to open output file.
writer = gcnew StreamWriter( args[ 2 ] );
// Redirect standard output from the console to the output file.
Console::SetOut( writer );
// Redirect standard input from the console to the input file.
Console::SetIn( gcnew StreamReader( args[ 1 ] ) );
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i want to learn about microsoft c++. please how can i get started?