wctest50.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 44 行

CPP
44
字号
// The following code demonstrates a bug in the iterated intrusive
//	list functions. If one tries to add at the end of the list, the data
//	is added at the beginning.
//
//
#include <wclistit.h>
#include <iostream.h>


#define NENTR	1000

int		vect[ 1000 ];
int		d1, dapp, dapp2, dapp3;

int main(void) {

	WCPtrDList< int > list;
	WCPtrDListIter< int > iter1(list);

	int i=0, j=0;	

	list.append( &vect[0] );
	++iter1;
	for(i=1; i<NENTR; i++) {
	    	vect[i] = i;
		iter1.append( &vect[i] );
		++iter1;
	}

	iter1.reset(list);
	++iter1;
	for(i=0; i<NENTR; i++) {
		j = *iter1.current();
		iter1 += 1;
		if (i<10)
			cout << "vect[" << i << "] = " << j << endl;
	}

	list.clear();

	cout << endl << endl;
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?