随笔分类 -  c

真爱
摘要:工作后就没写过C风格的代码了,刚用C风格写了些文件处理的笔试题,发现原来我的真爱还是C而不是C++。其实切换到C姿态写代码处理char,char*还是很好控制的,只是写C++的时候不想去考虑这些事情,感觉太繁琐细微的不应该是C++处理的。#include "stdio.h"#include "stdlib.h"#include "string.h"#include #include using namespace std;#define filepath "q1_test.txt"class fileReader{ 阅读全文

posted @ 2013-11-19 00:59 shizuka 阅读(191) 评论(0) 推荐(0)

'bout heap memory's controlling with "new" n "delete" and something like that
摘要:关于C++的堆空间的NEW和DELETE操作。C的MALLOC等和FREE也是同样的情形。图说明一切。DELETE/FREE之后手动赋值NULL。避免野指针的使用。阿弥陀佛。 阅读全文

posted @ 2012-11-02 10:21 shizuka 阅读(167) 评论(0) 推荐(0)

char*_n_alloc
摘要:感觉一直用C++,脑袋都快用SB了。用得自己什么样的轮子都不想造了,感觉自己快退化完了。上午突然对字符串又暧昧了。没办法,只能试了。#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define num 4int cpy(const char* str1, char* str2){ int i = 0; while((*(str2 + i) = *(str1 + i)) != '\0') { i++; } return 0;}int main(){ char* cp =... 阅读全文

posted @ 2012-02-13 12:27 shizuka 阅读(235) 评论(0) 推荐(0)

导航