Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
16
Добавлен:
01.05.2014
Размер:
836 б
Скачать
	#include <iostream.h>

	#include <stdio.h>

	#include <stdlib.h>

	#include <string.h>

	static char* outfile;

	static int a_flag, b_flag;



	int main( int argc, char* argv[] )

	{

		int ch;

		while ( (ch=getopt( argc, argv,"o:ab" )) != EOF ) 

			switch ( ch ) 			{

				case 'a': 	a_flag = 1;	// found -a

					break;

				case 'b':	b_flag = 1;		// found -b

					break;

				case 'o':	outfile = new char[strlen(optarg)+1];

					strcpy(outfile,optarg);	// found -o <file>

					break;

				case '?':	/* let getopt flags an eror message */

				default:	break;	// an illegal switch

		}



		/* no more switches. Scan the rest of non-switch arguments */

		for ( ; optind < argc; optind++ )

			cout << " non-switch argument: " << argv[optind] << endl;



		return 0;

	}
Соседние файлы в папке ch4