C语言for循环
摘要:for循环本来挺简单的,但是这几天教一个新手学习,让人抓狂,真的好难,下面是代码 1 #include <stdio.h> 2 int main() 3 { 4 5 printf(" 第一种情况 \n"); 6 /*c语言for循环几种情况: 7 1、for循环的作用范围 8 */ 9 int n=
阅读全文
posted @
2020-10-28 09:50
川洋
阅读(873)
推荐(0)
makefile:2: *** 遗漏分隔符 。 停止
摘要:注:除了tab分隔符问题,也要检查自己电脑tab与linux系统中的tab是否一致,有的tab是4个空格,有的是8个空格。 1、makefile文件中 我们在编写完makefile,然后在终端中 $make出现“makefile:2: *** 遗漏分隔符 。 停止。”问题,原因是在编写makefil
阅读全文
posted @
2020-10-27 10:35
川洋
阅读(4913)
推荐(0)
读取一段文本并输出文本中每个不同单词在文本中出现的次数
摘要:题目:编写一个程序,对一个文本文件进行分析,将不同单词的个数按大小排序,并输出该文件中每个不同单词在文本中出现的次数 例如:To be or not to be, that is the question.Whether in the mind to stuffer 应输出:to 3次,be 2次,
阅读全文
posted @
2019-03-27 00:10
川洋
阅读(929)
推荐(0)
大端小端问题
摘要:小端方式:先存储低位字节,后存储高位字节 大端方式:先存储高位字节,再存储低位字节 如16进制数0x12345678,按字节编址在内存中占的位置,内存地址从0x00开始:
阅读全文
posted @
2018-11-26 19:46
川洋
阅读(151)
推荐(0)
c++调用的函数前加 "::"代表什么意思
摘要:这里调用函数前加"::",代表调用的是全局函数,不是类自己的成员函数,下面是打印结果: global function class A
阅读全文
posted @
2018-03-16 14:24
川洋
阅读(8564)
推荐(3)
模板类单例模式
摘要:single.h 模板类单例模式与单例类似,只要理解单例模式,上面的代码就很好理解 main.cpp
阅读全文
posted @
2017-03-02 10:03
川洋
阅读(355)
推荐(0)
从vector继承的类
摘要:如果不理解Read类从public vecotr<AVP*>继承的话,可以这样,vector<AVP*> _avp; Read类从_avp继承,这样就很好理解了,直接看代码
阅读全文
posted @
2017-01-17 18:11
川洋
阅读(1280)
推荐(0)
使用位运算实现加法
摘要:a + b = a^b + ((a&b)<<1) a^b 表示不进位的位和 (a&b)<<1 表示向左移1为,表示进位
阅读全文
posted @
2017-01-06 15:14
川洋
阅读(344)
推荐(0)
c++虚函数调用及使用
摘要:#include using namespace std; class A { public: virtual int print()=0; }; class B: public A { public: virtual int get()=0; virtual int print() { coutp...
阅读全文
posted @
2016-11-10 15:35
川洋
阅读(225)
推荐(0)
c++中的宏 #define _CLASSDEF(name) class name
摘要:1 #include <iostream> 2 using namespace std; 3 #define _CLASSDEF(name) class name; \ 4 typedef name * P##name;\ 5 typedef name & R##name;\ 6 typedef n
阅读全文
posted @
2016-06-16 17:15
川洋
阅读(2304)
推荐(0)
va_copy
摘要:1 #include 2 #include 3 4 void func(char* format, va_list ptr); 5 void print(char* format,...); 6 7 void print(char* format,...) 8 { 9 va_list ptr; 10 va_list ptr_tmp; 11...
阅读全文
posted @
2016-05-27 11:34
川洋
阅读(1342)
推荐(0)
va_list结构体
摘要:http://stackoverflow.com/questions/4958384/what-is-the-format-of-the-x86-64-va-list-structure 这是我在stackoverflow上摘录的,上面是链接,va_list实际上是一个只有一个元素的结构体数组 I
阅读全文
posted @
2016-05-27 11:12
川洋
阅读(996)
推荐(0)
string类的代码实现
摘要:1 #ifndef __MYSTRING_H__ 2 #define __MYSTRING_H__ 3 #include 4 using namespace std; 5 class myString 6 { 7 friend ostream& operator(const char *p); 29 30 int operator(const myStr...
阅读全文
posted @
2016-05-05 15:46
川洋
阅读(290)
推荐(0)
c语言内存对齐问题
摘要:#include <stdio.h> #pragma pack(4)struct stu{char a;short b;int c;char d;};int main(){printf("%d\n", sizeof(struct stu));return 0;}#pragma pack(4) //
阅读全文
posted @
2016-03-22 12:00
川洋
阅读(235)
推荐(0)