
C/C++
文章平均质量分 51
nuoshueihe
这个作者很懒,什么都没留下…
展开
-
HexStrToByte
void HexStrToByte(const char* source, unsigned char* dest, int sourceLen){ short i; unsigned char highByte, lowByte;for (i = 0; i < sourceLen; i += 2){ highByte = source[i]; lowByte = sou...原创 2020-03-26 19:33:49 · 1297 阅读 · 0 评论 -
C++ 之委托构造函数& new(this)的运用
struct Rect{ Rect(){ new(this) Rect(1, 2, 3, 4, 5, 6);// left =1;// top =2; cout <<"left second:" << left <<endl; } Rect(int l, int t, int r, ...原创 2019-10-14 16:22:53 · 2254 阅读 · 0 评论 -
QT 编译C++11
TEMPLATE = appCONFIG += console c++11CONFIG -= app_bundleCONFIG -= qtSOURCES += main.cppQMAKE_CXXFLAGS += -fno-elide-constructors //禁用编译器优化QMAKE_CXXFLAGS += -std=c++11 //支持C++11...原创 2019-10-14 15:07:49 · 860 阅读 · 0 评论 -
C++11 std::move 和std::forward
#include <iostream>#include <type_traits>#include <typeinfo>#include <memory>using namespace std;struct A{ A(int&& n) { cout << "rvalue ov...原创 2019-10-12 15:01:17 · 135 阅读 · 0 评论 -
螺旋矩阵
#include #include #include using namespace std;const int N = 100;int data[N + 1][N + 1];enum DIRECTION{ RIGHT, DOWN , LEFT, UP};int max(int a,int b){ return (a>b?原创 2009-04-29 16:40:00 · 587 阅读 · 0 评论 -
螺旋
#include using namespace std;int foo(int x, int y){ int t = (x>0?x:-x) > (y>0?y:-y) ? (x>0?x:-x) : (y>0?y:-y); int u = t + t; int v = u - 1; v = v * v + u; if(x == -t) v += u +原创 2009-05-05 11:28:00 · 468 阅读 · 0 评论 -
c++文件读写
void main(){ ifstream in_is; in_is.open("a.txt",ios::in); ofstream out_os; out_os.open("b.txt",ios::out|ios::trunc); if (out_os==NULL) { cout<<"out_os error"<<endl; } char line[10原创 2009-09-14 10:46:00 · 476 阅读 · 0 评论 -
socket
<br />//TcpClient.cpp<br />#include <Winsock2.h><br />#include <stdio.h><br />void main()<br />{<br /> WORD wVersionRequested;<br /> WSADATA wsaData;<br /> int err;<br /> <br /> wVersionRequested = MAKEWORD( 1, 1 );<br /> <br /> err = WSAStartup( wVersionR翻译 2010-12-23 21:39:00 · 523 阅读 · 0 评论 -
在C++ 重复读取文件中的最后一行的解决办法
<br /> #include <iostream>#include <fstream>#include <stdlib.h>using namespace std;void main(){ ifstream ifs; ifs.open("a.txt");// ifs.seekg(-10,ios::end); char str[11]; cout<<sizeof("this is c")<<endl; memset(str,0,11);// ifs.rea原创 2010-12-23 22:27:00 · 3792 阅读 · 0 评论 -
愤怒的小狐狸blog
http://blog.youkuaiyun.com/MONKEY_D_MENG?viewmode=list原创 2012-01-11 22:30:59 · 554 阅读 · 0 评论 -
linux多线程博客
http://blog.youkuaiyun.com/feixiaoxing/article/details/7064559原创 2012-01-13 16:16:57 · 463 阅读 · 0 评论 -
mount
mount -t cifs -o username=**,password=*** //10.10。。/a ../a原创 2012-01-13 16:19:25 · 351 阅读 · 0 评论 -
FFMPEG学习
http://blog.youkuaiyun.com/ym012/article/details/6537788http://www.ffmpeg.com.cn/index.php/SDK%E4%B9%8B%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8原创 2012-03-16 15:42:26 · 376 阅读 · 0 评论 -
记录的网站
http://www.cnblogs.com/Xiao_bird/archive/2010/03/26/1696908.htmlhttp://blog.youkuaiyun.com/xingyu19871124/article/details/4320210http://blog.youkuaiyun.com/xfding/article/details/5467952http://www.ibm.com/d转载 2012-05-03 18:07:52 · 583 阅读 · 0 评论 -
java data
import java.util.*; import java.text.*; import java.util.Calendar; public class VeDate { /** * 获取现在时间 * * @return 返回时间类型 yyyy-MM-dd HH:mm:ss */ public static Date getNo原创 2012-05-29 17:08:50 · 3335 阅读 · 2 评论 -
java study 001
import java.io.BufferedReader;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.util.HashMap;import java.util.Map;import java.io.File;publi原创 2012-05-30 16:36:40 · 446 阅读 · 0 评论 -
java studyd 003 --object clone
class Point implements Cloneable{ int x; int y; Date dt; Point(int x, int y) { this.x=x; this.y=y; dt = new Date(); SimpleDateFormat simdate = new SimpleDateFormat("yyyy"原创 2012-06-01 09:12:04 · 354 阅读 · 0 评论 -
java study 005 thread
class SimpleThread extends Thread{ public void run() { int count=0; while(count { System.out.println(Thread.activeCount()); String name=Thread.currentThread().getName(); cou原创 2012-06-01 11:02:55 · 447 阅读 · 0 评论 -
java study 002 --inner class
import java.util.*;public class Inerclasstest { public static void main(String[] args) { Outer out =new Outer(); // out.print(); //main 中直接访问内部类 //main 中不能直接产生innerd object,原创 2012-05-31 15:11:19 · 401 阅读 · 0 评论 -
java study 003--the method is the same, resolve way---inner class
interface Machine{ void run();}class persion{ void run() { System.out.println("persion run"); }}//当一个类继承的类和实现的接口中的方法重复时,可以用内部类去解决class robet extends persion{ class machin原创 2012-05-31 15:58:49 · 458 阅读 · 0 评论 -
java study IO//FILE pipe
import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;impo原创 2012-06-01 16:24:18 · 454 阅读 · 0 评论 -
孙鑫java视频——多线程总结
//模拟火车票售票系统class TicketsThread{ public static void main(String args[]) { SellThread mythread=new SellThread(); new Thread(mythread).start();原创 2012-06-05 09:39:54 · 1200 阅读 · 0 评论 -
sscanf函数的高级用法
sscanf函数的高级用法转载时请注明出处:http://blog.youkuaiyun.com/absurd/大家都知道sscanf是一个很好用的函数,利用它可以从字符串中取出整数、浮点数和字符串等等。它的使用方法简单,特别对于整数和浮点数来说。但新手可能并不知道处理字符串时的一些高级用法,这里做个简要说明吧。1. 常见用法。charstr[51原创 2012-06-07 09:23:36 · 315 阅读 · 0 评论 -
socket server.c & client.c
/* A simple server in the internet domain using TCP The port number is passed as an argument */#include #include #include #include #include #include #include void error(const char原创 2012-06-11 15:32:57 · 822 阅读 · 0 评论 -
socket
点击打开链接原创 2012-06-11 15:36:23 · 344 阅读 · 0 评论 -
动态链接库的制作与调用
[root@localhost so_file]# ls so_test.h test_a.c test_b.c test.c test_c.c [root@localhost so_file]# [root@localhost so_file]# cat so_test.h #include void test_a(); void test_b(); v原创 2012-06-29 10:47:00 · 854 阅读 · 3 评论 -
单子(Singleton)设计模式
单子(Singleton)设计模式:在整个应用中只有一个实例存在,创建的两个实例都指向同一个对象。创建的步骤:1.构造器要私有。2.用一个私有的静态变量引用实例。3.用一个公有静态方法获得实例。如:/* 一。为什么要实现单一模式,是因为我创建的两个实例都指向同一个对象 二。要实现单一模式需要进行下面三步: 1.构造器私有 2。用一个私原创 2012-06-29 14:06:40 · 517 阅读 · 0 评论 -
Linux动态链接库.so文件的创建与使用
Linux动态链接库.so文件的创建与使用本文以一个简单的例子,介绍linux下动态库的创建和使用操作。其中就无法找到动态库文件的问题简单介绍处理办法。动态链接库文件在windows平台下往往以.dll为后缀,而在linux平台则一般以.so为后缀,so是shared object的缩写。感觉在linux下构建动态链接库文件比在windows下省点功夫,使用gcc编译器的话,只原创 2012-06-29 11:19:35 · 1578 阅读 · 1 评论 -
C++设计模式--单一对象模式<Singleton>
C++设计模式--单一对象模式原创 2012-06-29 17:23:42 · 585 阅读 · 0 评论 -
BE_32
#include #include #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ (((uint8_t*)(x))[1] << 16) | \ (((uint8_t*)(x))[2] << 8) | \原创 2012-07-21 11:16:50 · 618 阅读 · 0 评论 -
print all elements in a deque
/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 19原创 2012-08-10 17:12:38 · 406 阅读 · 0 评论 -
Remove all elements with values less than 50
/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 19原创 2012-08-10 17:15:02 · 582 阅读 · 0 评论 -
Use find the search an element in deque
#include #include #include #include // For findusing namespace std;int main(){ int x[5] = {1, 2, 3, 4, 5}; deque deque1(&x[0], &x[5]); // Search for the first occurrence deque::ite原创 2012-08-10 17:16:58 · 411 阅读 · 0 评论 -
Insert 'value' into every element but the first
/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 19原创 2012-08-10 17:20:21 · 348 阅读 · 0 评论 -
Insert elements in vector to deque
#include #include #include using namespace std;int main(){ int data[5] = { 6, 8, 7, 6, 5 }; vector v(5, 6); //5 element vector deque d(data, data + 5); deque::iterator p;原创 2012-08-10 17:22:17 · 364 阅读 · 0 评论 -
Remove first and last element
/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 19原创 2012-08-10 17:23:30 · 391 阅读 · 0 评论 -
Using Binary I/O with Array-Based Streams
#include #include using namespace std;int main(){ char *p = "this is a test\1\2\3\4\5\6\7"; istrstream ins(p); char ch; while (!ins.eof()) { // read and display bina原创 2012-08-10 17:33:43 · 1079 阅读 · 0 评论 -
Use exceptions to watch for and handle I/O errors.
#include #include #include using namespace std;struct inventory { char item[20]; int quantity; double cost;};int main(){ int completion_status = 0; ofstream fout; fout.exceptio原创 2012-08-10 17:38:35 · 1068 阅读 · 0 评论 -
Use eof() to read and display a text file.
#include #include using namespace std;int main(int argc, char *argv[]){ char ch; ifstream fin("text.txt"); if(!fin) { cout << "Cannot open file.\n"; return 1; } do { fin原创 2012-08-10 17:41:08 · 453 阅读 · 0 评论 -
While it is not the end of a file, output file line by line
#include #include using namespace std;int main () { char buffer[256]; ifstream myfile ("test.txt"); while (! myfile.eof() ) { myfile.getline (buffer,100); cout << buffer << endl; } retu原创 2012-08-10 17:42:21 · 375 阅读 · 0 评论