随笔分类 -  C/C++

1
安装lua和openresty
摘要:#### ubuntu 16.04 64bit 安装Lua luajit 及openresty 1 安装lua ,因为luajit 支持lua5.1较好.貌似不支持5.2和5.3作为学习,我就安装5.1 sudo apt-get update sudo apt-get install lua5.1 阅读全文
posted @ 2016-11-23 13:08 c3tc3tc3t 阅读(457) 评论(0) 推荐(0)
fgets读取文件时的注意事项
摘要:1 文本文件 a.txt 内容如下 输出结果 总结: fgets读取时,如果指定的读取大小,小于实际行大小 那么 不添加\n做结尾,使用\0 ,然后接着读取没读完的当前行数据作为新的一行开始 fgets读取时,如果指定读取大小.大于实际行大小,那么将\n添加到末端.再添加\0 \0不算做有效长度里的 阅读全文
posted @ 2016-10-06 15:25 c3tc3tc3t 阅读(2378) 评论(0) 推荐(0)
ubuntu下设置clion是使用clang和clang++
摘要:链接 http://stackoverflow.com/questions/31725681/how-to-setup-clion-with-portable-clang-on-ubuntu I got the answer from CLion blog and it works and here 阅读全文
posted @ 2016-10-04 13:45 c3tc3tc3t 阅读(4742) 评论(0) 推荐(0)
Linux 下没有conio.h 已解决
摘要:原文:http://blog.sina.com.cn/s/blog_6a95e00b0100zqvf.html #include <stdio.h>//#include <conio.h>void main(){ char ch; for(;;){// system("stty -echo"); c 阅读全文
posted @ 2016-10-04 13:16 c3tc3tc3t 阅读(3353) 评论(0) 推荐(2)
声明指针的时候一定要初始化一个确定的值
摘要:今天看c++ primer plus才看到这个知识点,以前没注意,一定要在指针初始化的时候为他赋一个确定的值c++ primer plus 101页 4.7.2 阅读全文
posted @ 2015-12-09 22:44 c3tc3tc3t 阅读(441) 评论(0) 推荐(0)
利用快慢指针快速得到链表中间节点
摘要://利用快慢指针快速得到链表中间节点int getMiddleNodeValue(LIST * l) { NODE * search, * middle; search = l->head; middle = l->head; while (NULL != searc... 阅读全文
posted @ 2015-05-18 11:57 c3tc3tc3t 阅读(314) 评论(0) 推荐(0)
数据结构之C语言模拟整数数组实现
摘要:1 #include 2 #include 3 #include 4 5 typedef struct Arr 6 { 7 int * pBase = NULL; //数组首地址 8 int cnt; //当前元素个数 9 int len; //数... 阅读全文
posted @ 2015-05-06 18:23 c3tc3tc3t 阅读(283) 评论(0) 推荐(0)
解决 eclipse cdt 运行时控制台乱码解决
摘要:1 点击黑色 倒三角 按钮 选择 run configurations2 2.1 点击new 添加 LANG = en_US 2.2 选择 replace native environment with specied environment 阅读全文
posted @ 2015-01-10 17:07 c3tc3tc3t 阅读(396) 评论(0) 推荐(0)
指针和二位数组
摘要:int a[3][4] = { 0, 1,2,3,4,5,6,7,8,9,11,12}; printf("\n%d,%d", a,*a); //两个一样的16进制地址 printf("\n%d,%d", sizeof(a), sizeof(*a)); // 48 16 ... 阅读全文
posted @ 2014-12-20 13:55 c3tc3tc3t 阅读(168) 评论(0) 推荐(0)
利用指针初始化一个三维数组,只使用一层循环
摘要:#define _CRT_SECURE_NO_WARNINGS#include #include #include void main() { int a[3][5][3]; int num = 0; for (int * b = &a[0][0][0]; b < (&a[0][... 阅读全文
posted @ 2014-12-17 19:58 c3tc3tc3t 阅读(481) 评论(0) 推荐(0)
用一层for循环初始化三维数组
摘要:int a[3][4][5]; for (int i = 0; i < 3 * 4 * 5; i++) { a[i / 20][(i / 5) % 4][i % 5] = i; printf("%-2d,%-2d,%-6d", i / 20, (i / 5)... 阅读全文
posted @ 2014-12-17 16:35 c3tc3tc3t 阅读(337) 评论(0) 推荐(0)
两种初始化2维数组方法
摘要:#define _CRT_SECURE_NO_WARNINGS#include #include #include void main() { int num[3][4]; for (int i = 0; i #include #include void main() { int ... 阅读全文
posted @ 2014-12-16 21:34 c3tc3tc3t 阅读(290) 评论(0) 推荐(0)
输入一个正整数n (1<n<=10),生成 1个 n*n 方阵 求出对角线之和
摘要:#define _CRT_SECURE_NO_WARNINGS#include #include #include void main() { int n = 0; scanf("%d", &n); int a[50][50] = { 0 }; int result = 0... 阅读全文
posted @ 2014-12-16 21:24 c3tc3tc3t 阅读(1299) 评论(0) 推荐(0)
codeblocks 控制台输出乱码
摘要:解决办法如图如果你和我用的一样是kde环境 把Terminal to launch console programs那个选项改成 上图 konsole -e如果你用的是gnome环境 把Terminal to launch console programs那个选项改成 gnome-term... 阅读全文
posted @ 2014-11-26 11:59 c3tc3tc3t 阅读(528) 评论(0) 推荐(0)
网路连接出现意外错误
摘要:在 打开 运行框中, 键入 regsvr32 %systemroot%\system32\netshell.dll在 打开 运行框中, 键入 regsvr32 %systemroot%\system32\ole32.dll , 然后单击 确定 阅读全文
posted @ 2014-01-06 15:49 c3tc3tc3t 阅读(230) 评论(0) 推荐(0)
二叉树先知道后序和中序,求先序
摘要:比如已知后序DABEC 中序DEBAC,求先序后序DABEC 中序DEBAC由后序最后一个字母知:整个树的开始结点为C;由中序C的位置知:C前面的为结点C的左子树;C后面的为结点C的右子树;所以经过第一次推理,C为根结点,DEBA为其左子树;然后去掉C,考虑下面的左子树;后序DABE 中序DEBA由后序最后一个字母知:整个左子树的开始结点为E;由中序E的位置知:E前面的为结点E的左子树;E后面的为结点E的右子树;所以经过第一次推理,E为开始结点,D为E的左结点.BA为E的右结点.然后去掉DE,考虑下面E的右子树;后序AB 中序BA易知:B为根结点,A为其右结点.所以整个树为:C(E(D,B(. 阅读全文
posted @ 2013-08-18 08:49 c3tc3tc3t 阅读(501) 评论(0) 推荐(0)
C语言实现链表
摘要:#include#include#includetypedef struct Node { int data; struct Node * pNode } NODE,* PNODE;PNODE create_list();void show_list(PNODE);int is_emp(PNODE);int length_list(PNODE);int insert_list(PNODE,int,int);int delete_list(PNODE,int,int *);void sort_list(PNODE);int main(void) { PNODE p = create_list() 阅读全文
posted @ 2013-07-20 20:00 c3tc3tc3t 阅读(277) 评论(0) 推荐(0)
C的笔记
摘要:& : 1和谁& 等于谁 1&1 =1 1&0=0 0和谁& 等于0 0&1=0 0&0=0用途:把某位变1/0|:0和谁|还是谁,1和谁|还是1^:1和谁^就是谁取反,0和谁^就是谁-----------谁或1还是1 ,谁或0还是谁谁与1还是谁,谁与0还是0谁异或0还是谁,谁异或1就是他取反 阅读全文
posted @ 2013-05-11 16:14 c3tc3tc3t 阅读(155) 评论(0) 推荐(0)
想成为 Linux 下专业的 C/C++ 程序员,下面工具都是必须要了解的。
摘要:1. 基本命令http://mally.stanford.edu/~sr/computing/basic-unix.htmlhttp://pangea.stanford.edu/computing/unix/shell/commands.phphttp://infohost.nmt.edu/tcc/help/unix/unix_cmd.html2. 编辑器– vi, Emacshttp://www.atmos.albany.edu/deas/atmclasses/atm350/vi_cheat_sheet.pdfhttp://cmgm.stanford.edu/classes/unix/ema 阅读全文
posted @ 2012-08-28 12:58 c3tc3tc3t 阅读(223) 评论(0) 推荐(0)
C语言模拟静态双向列队
摘要:#include <stdio.h>#include <malloc.h>typedef struct Queue{ int * pBase; int front; int rear;} QUEUE;void init(QUEUE *);int en_queue(QUEUE *,int);void traverse_queue(QUEUE *);int full_queue(QUEUE *);int out_queue(QUEUE *,int *);int emput_queue(QUEUE * );int main(void){ QUEUE Q; int val; i 阅读全文
posted @ 2011-10-21 11:22 c3tc3tc3t 阅读(205) 评论(0) 推荐(0)

1