Exemplo n.º 1
0
int main(int argc,char *argv[])
{
	pid_t pid;
	TELL_WAIT();

	if ((pid = fork()) < 0){
		perror("fork");
	}else if (pid == 0){
		TELL_PARENT(getppid());
		WAIT_PARENT();
		chara("output from child\n");
	}else{
		chara("output from parent\n");
		TELL_CHILD(pid);
	}
	exit(0);
}
Exemplo n.º 2
0
int main ()
{
  //!NOTE: should work perfectly now.
  ExampleOfUsingClassComp();

  // empty set that can contain ints
  std::set<int> first;

  int myints[]= {40,50,10,30,20};
  std::set<int> second (myints,myints+5);
  // This should be printed in order; set has an internal
  // comparator that 'looks' and 'works' like those given above.
  //!NOTE: We replace the for loop below with 'PrintSetContents'
  // for(std::set<int>::const_iterator cit = second.begin();
  //     cit != second.end(); cit++)
  //   std::cout << (*cit) << " ";
  // std::cout << std::endl;
  PrintSetContents(second.begin(), second.end());

  // a copy of second
  std::set<int> third (second);

  // Constructor that takes iterators
  std::set<int> fourth (second.begin(), second.end());

  // class/struct as Compare object
  std::set<int,classcomp<int> > fifth;

  // function pointer as Compare method
  bool(*fn_pt)(int,int) = fncomp;
  std::set<int,bool(*)(int,int)> sixth (second.begin(),
                                        second.end(), fn_pt);
  // Should print elements reversed
  for(std::set<int,bool(*)(int,int)>::iterator it = sixth.begin();
      it != sixth.end(); it++)
    std::cout << (*it)  << " ";
  std::cout << std::endl;

  char str[] = "For... He's a Jolly Good Fellow!.."
               "For He's a Jolly Good Fellow!..."
               "And so say all of us, and so say all of us."
               "I WISH TO WISH THE WISH YOU WISH TO WISH,"
               "BUT IF YOU WISH THE WISH THE WITCH WISHES, "
               "I WON'T WISH THE WISH YOU WISH TO WISH."
               "@#^&@)*(^%$#!$#&(*#!@$#!~~`1;/.,''`)";
  std::set<char> chara(str, str + strlen(str));
  //!NOTE: We replace the for loop below with 'PrintSetContents'
  // for(std::set<char>::const_iterator cch = chara.begin();
  //     cch != chara.end(); cch++)
  //   std::cout << (*cch);
  // std::cout << std::endl;
  //!TODO: comment out the line below, compile & run. Note what
  //       happens.
  PrintSetContents(chara.begin(), chara.end());
  return 0;
}
Exemplo n.º 3
0
int main()
{
	int place;	//主人公の位置
	int i=0;	//test用

	player chara(2,2);	//主人公の初期位置
	event map;
	while(i < 20){
		place = chara.move();
		//placeの番号によってイベントを変更する。
		map.event_map(place);	
	i++;
	}
	return(0);
}