Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
16
Добавлен:
01.05.2014
Размер:
662 б
Скачать
	/* source file name: test_setjmp.c */

	#include <iostream.h>

	#include <setjmp.h>

	static jmp_buf loc;

	int main() 

	{

		int retcode, foo();

		

		if ( (retcode=setjmp( loc )) != 0 ) 	{	// error recovery

			cerr << "Get here from longjmp. retcode=" << retcode << endl;

			return 1;

		}

		/* normal flow of program */

		cout << "Program continue after setting loc via setjmp...\n";

		foo();

		cout << "Should never get here ....\n";

		return 1;

	}



	int foo()

	{

		cout << "Enter foo. Now call longjmp....\n";

		longjmp (loc, 5);

		cout << "Should never gets here....\n";

		return 2;

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