My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
HelloWorld  
Hello World example
Updated Nov 14, 2011 by hugo.arregui

The following example shows a Hello World application. It accepts one parameter, a string, to whom say hello. This parameter is -n for the short option, and --name for the long one. If no option is provided, then the World is greeted.

#include <iostream>
#include "getopt_pp.h"

using namespace GetOpt;
using namespace std;

int main(int argc, char* argv[])
{
	string who;
	
	GetOpt_pp ops(argc, argv);
	
	ops >> Option('n', "name", who, "world" );		/* the default name is 'world' */
	
	cout << "Hello " << who << "!" << endl;
	
	return 0;
}

Sign in to add a comment
Powered by Google Project Hosting