数据加载中……

2014年7月5日

博客搬家了,新的博客地址 www.k-door.com

新的博客地址 www.k-door.com

posted @ 2014-07-05 18:22 Stone xin 阅读(165) | 评论 (0)编辑 收藏

2013年6月27日

【原创】warning no newline at end of file 的解决办法

     摘要:   阅读全文

posted @ 2013-06-27 13:44 Stone xin 阅读(966) | 评论 (0)编辑 收藏

2013年5月3日

【原创】正确使用map的erase方法【修正版】

在好多不负责任的博客中普及了一些错误的map删除元素的方法。
现在给出纠正。

首先,map的erase方法有三种形式

(1)
 void erase (iterator position); 
(2)
     size_type erase (const key_type& k); 
(3)
 void erase (iterator first, iterator last);

第3种没有什么歧义,不用细说了。
最有歧义的就是第一种和第二种。

有返回值的接口,是删除key为参数的。返回值是删除的数量。因为map中key不会重复,所以,如果key存在,则返回的是1,否则,返回是0;

如果是调用的iter接口,则删除的是迭代器位置的元素。
如果只删除一个元素,直接 map.erase(iter);就好了。
如果用循环。
while(iter!=map.end)
{
    if(condition)
   {
      map.erase(iter++);
   }else{
      ++iter;   
   }
}
官方手册地址:
http://www.cplusplus.com/reference/map/map/erase/

posted @ 2013-05-03 11:29 Stone xin 阅读(1912) | 评论 (0)编辑 收藏

2013年2月18日

开源图形库 c语言-图形图像库 集合[转]

     摘要: Google三维API O3D  O3D 是一个开源的 Web API 用来在浏览器上创建界面丰富的交互式的 3D 应用程序。这是一种基于网页的可控3D标准。此格式期望真正的基于浏览器,独立于操作系统之外,并且支持主流的3D显卡,这样就可以在网页中实现效果逼真的3D动画。在线演示:http://o3... 更多O3D信息   最新新闻: 谷歌联手Mozilla基金开发3D互联网图像技术发...  阅读全文

posted @ 2013-02-18 15:28 Stone xin 阅读(5191) | 评论 (0)编辑 收藏

2012年12月12日

实现简单的POST数据【修正版】

     摘要: 实现简单的POST数据【修正版】  阅读全文

posted @ 2012-12-12 17:46 Stone xin 阅读(400) | 评论 (0)编辑 收藏

2012年11月20日

Chrome所涉及26个开源代码

     摘要: Chrome所涉及26个开源代码  阅读全文

posted @ 2012-11-20 21:48 Stone xin 阅读(376) | 评论 (0)编辑 收藏

2012年9月1日

[转载]windows路径操作API函数

     摘要: windows路径操作API函数  阅读全文

posted @ 2012-09-01 14:56 Stone xin 阅读(5624) | 评论 (0)编辑 收藏

2012年5月17日

Windows程序增加控制台

#include "StdAfx.h"
#include "Console4GUI.h"


Console4GUI::Console4GUI(void)
{
    AllocConsole();   // Create a new console window 

    int hCrun;    
    hCrun = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE),_O_TEXT);
    FILE    *file  = _fdopen(hCrun, "w");

    // use default stream buffer
    setvbuf(file, NULL, _IONBF, 0);
    *stdout = *file;

    std::cout<<"控制台启动"<<std::endl;
}

Console4GUI::~Console4GUI(void)
{
    FreeConsole();  // Close the console window  
}
#pragma once
#include <fcntl.h>
#include <io.h>
#include <iostream>
class Console4GUI
{
public:
    Console4GUI(void);
    ~Console4GUI(void);
};

posted @ 2012-05-17 16:58 Stone xin 阅读(277) | 评论 (0)编辑 收藏

不定长参数格式化输出(支持中文字符)

#include <iostream>
#include <string>
void myformat(const char *fmt, )
{
va_list ap;
va_start(ap, fmt);
wchar_t buf[2048];
vswprintf(buf,fmt,ap);
va_end(ap);
std::wcout.imbue(std::locale("chs"));
std::wcout<<buf<<std::endl;
}
如果要返回值:
#include <iostream>
#include <string>
std::wstring myformat(const char *fmt, )
{
va_list ap;
va_start(ap, fmt);
wchar_t buf[2048];
vswprintf(buf,fmt,ap);
va_end(ap);
std::wstring str = std::wstring(buf);
return str;
}

posted @ 2012-05-17 16:52 Stone xin 阅读(514) | 评论 (0)编辑 收藏

2012年4月9日

Boost异步IO

     摘要: Boost异步IO  阅读全文

posted @ 2012-04-09 17:59 Stone xin 阅读(415) | 评论 (0)编辑 收藏