예제 #1
0
/*--------------------------------------ConsoleSchemeHandler::Rep::makeStream-+
|                                                                             |
+----------------------------------------------------------------------------*/
iostream * ConsoleSchemeHandler::Rep::makeStream(
   URI const & uri, ios__openmode om
) {
   iostream * io;
   switch (uri.getPath()[0]) {
   case 'i':
      io = new iostream(getCin().rdbuf());
      break;
   case 'o':
      io = new iostream(getCout().rdbuf());
      break;
   case 'e':
      io = new iostream(getCerr().rdbuf());
      break;
   }
   #if defined _WIN32
      /*
      | delbuf(0), in Microsoft stream jargon, means that the stream buffer
      | won't be deleted when the stream is deleted.  For Metrowerks, we
      | don't take permission to delete a streambuf that doesn't belong to
      | to us (JaxoStreams.)  For GCC, if ISO 14882, it's sure that the
      | streambuf is not deleted.  For GCC under 3.0, I hope so -- and also
      | for non-GCC.  Otherwise, we gotta use the 3rd parameter of "setb()"
      */
      io->delbuf(0);
   #endif
   return io;
}
void main() {
	int ret = 0;
	//char *p = "abcd1111abcd222abcd3333";
	char *p = NULL;
	int ncout = 0;
	char *subp = "abcd";

	ret = getCout(p, subp, &ncout);
	if (ret != 0) {
		printf("func getCout() err:%d \n", ret);
		return ;
	}
	printf("coutn:%d \n", ncout);
	system("pause");

}