上一页 1 2 3 4 5 6 ··· 15 下一页
摘要: 原来,UDP通信,比我想象中简单的多!// WindowsSocketServer.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <string>#include <Windows.h>#include <Winsock2.h>#include <fstream>#pragma comment(lib,"Ws2_32.lib")using namespace std;#define PORT 8080#d 阅读全文
posted @ 2012-07-01 16:42 Kingdom_0 阅读(529) 评论(0) 推荐(0) 编辑
摘要: 1 // WindowsSocketServer.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include <iostream> 6 #include <string> 7 #include <Windows.h> 8 #include <Winsock2.h> 9 #include <fstream> 10 #pragma comment(lib,"Ws2_32.lib") 11 12 using namespace std; 1 阅读全文
posted @ 2012-07-01 11:03 Kingdom_0 阅读(11451) 评论(0) 推荐(0) 编辑
摘要: // TimerTest.cpp : Using STL functions//并集,交集,差集,根据bound获取特定子集#include "stdafx.h"#include <iostream>#include <string>#include <vector>#include <set>#include <algorithm>#include <iterator>using namespace std;int _tmain(int argc, _TCHAR* argv[]){ const int 阅读全文
posted @ 2012-06-27 11:46 Kingdom_0 阅读(1134) 评论(0) 推荐(0) 编辑
摘要: 在STL中基本容器有: string、vector、list、deque、set、mapset 和map都是无序的保存元素,只能通过它提供的接口对里面的元素进行访问set:集合, 用来判断某一个元素是不是在一个组里面,使用的比较少map:映射,相当于字典,把一个值映射成另一个值,如果想创建字典的话使用它好了string、vector、list、deque、set 是有序容器1.stringstring 是basic_string<char> 的实现,在内存中是连续存放的.为了提高效率,都会有保留内存,如string s= "abcd",这时s使用的空间可能就是2 阅读全文
posted @ 2012-06-27 10:53 Kingdom_0 阅读(250) 评论(0) 推荐(0) 编辑
摘要: // TimerTest.cpp : Using STL functions//#include "stdafx.h"#include <iostream>#include <string>#include <vector>#include <algorithm>using namespace std;struct Review{ string title ; int rating ;};bool operator<(const Review &r1,const Review &r2);bool wors 阅读全文
posted @ 2012-06-26 19:22 Kingdom_0 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必担心内存是否足够、字符串长度等等,而且作 为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至是100%)的需要。我们可以用 = 进行赋值操作,== 进行比较,+ 做串联(是不是很简单?)。我们尽可以把它看成是C++的基本数据类型。 好了,进入正题………首先,为了在我们的程序中使用string类型,我们必须包含头文件 。如下: #include //注意这里不是string.h string.h是C字符串头文件1.声明一个C++字符串声明一个字符串变量很简单: string Str;这样我 阅读全文
posted @ 2012-06-25 17:14 Kingdom_0 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 在进行多线程编程时,难免还要碰到两个问题,那就线程间的互斥与同步:线程同步是指线程之间所具有的一种制约关系,一个线程的执行依赖另一个线程的消息,当它没有得到另一个线程的消息时应等待,直到消息到达时才被唤醒。线程互斥是指对于共享的进程系统资源,在各单个线程访问时的排它性。当有若干个线程都要使用某一共享资源时,任何时刻最多只允许一个线程去使用,其它要使用该资源的线程必须等待,直到占用资源者释放该资源。线程互斥可以看成是一种特殊的线程同步(下文统称为同步)。线程间的同步方法大体可分为两类:用户模式和内核模式。顾名思义,内核模式就是指利用系统内核对象的单一性来进行同步,使用时需要切换内核态与用户态,而 阅读全文
posted @ 2012-06-25 11:32 Kingdom_0 阅读(698) 评论(0) 推荐(0) 编辑
摘要: 1 // MultiThreadTest.cpp : Defines the entry point for the console application. 2 // Thread 创建,挂起等 3 4 #include "stdafx.h" 5 #include<Windows.h> 6 #include<iostream> 7 #include<string> 8 using namespace std; 9 DWORD WINAPI myThread(LPVOID argv);//声明一个线程函数10 int _tmain(int 阅读全文
posted @ 2012-06-25 10:29 Kingdom_0 阅读(724) 评论(0) 推荐(0) 编辑
摘要: // WindowsSocketServer.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <Windows.h>#include <Winsock2.h>#pragma comment(lib,"Ws2_32.lib")using namespace std;#define PORT 8081#define IP_ADDRESS "172.16.20.181"DWORD WINAPI ClientThrea 阅读全文
posted @ 2012-06-21 18:20 Kingdom_0 阅读(1050) 评论(3) 推荐(0) 编辑
摘要: bool CreateXmlFile(const char *szFileName){ //创建xml文件,szFileName为文件保存的路径,若创建成功返回true,否则false try { //创建一个XML的文档对象 TiXmlDocument *myDocument=new TiXmlDocument(); //创建一个Person 元素并连接 TiXmlElement *RootElement=new TiXmlElement("Persons"); myDocument->LinkEndChild(RootElement); //创建一个Person元 阅读全文
posted @ 2012-06-19 19:32 Kingdom_0 阅读(960) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 15 下一页