
C语言
文章平均质量分 52
ZFZF294990051
这个作者很懒,什么都没留下…
展开
-
strdup 函数
strdup()主要是拷贝字符串s的一个副本,由函数返回值返回,这个副本有自己的内存空间,和s不相干。char *strdup(const char *s){ char *t = NULL; if (s && (t = (char*)malloc(strlen(s) + 1))) strcpy(t, s); ret原创 2011-11-25 16:37:29 · 391 阅读 · 0 评论 -
C 双向链表简单操作
#include #include #include /* 双链表节点定义 */typedef struct tagStDulNode{ int iData; struct tagStDulNode *pstPrior; /* 指向前驱节点 */ struct tagStDulNode *pstNext; /* 指向后继节点 */}StDulNode;/* 创建具有iNu原创 2013-08-24 11:11:56 · 607 阅读 · 0 评论 -
C Hash表--链地址法
/** * 已知一组关键字为{19, 14, 23, 01, 68, 20, 84, 27, 55, 11, 10, 79}, * 按Hash函数为H(key) = key MOD 13和链地址法处理冲突构造Hash表。 * 结果如图: * Hash[0] * Hash[1]-->01-->14-->27-->70-->null * Hash[2] * Hash[3]-->55-->原创 2013-08-26 18:26:09 · 898 阅读 · 0 评论 -
C++ String面试题
#include using namespace std;class String{private: char *pc;public: //注意const的使用 String(const char *pcStr = NULL) //默认参数 { cout<<"construct"<<endl; if (NULL != pcStr) { pc = new ch原创 2013-10-09 13:34:43 · 566 阅读 · 0 评论 -
大数据 加法
#include #include #include "stdafx.h"#include #define MAX(i, j) (((i) > (j)) ? (i) : (j))void swap(char *pc1, char *pc2){ *pc1 = *pc1 ^ *pc2; *pc2 = *pc1 ^ *pc2; *pc1 = *pc1 ^ *pc2;}void原创 2013-10-12 10:23:04 · 754 阅读 · 0 评论 -
华为 机试题
// MyC.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include /* 通过键盘输入一串小写字母(a~z)组成的字符串。请编写一个字符串过滤程序,若字符串中出现多个相同的字符,将非首次出现的字符过滤掉。比如字符串“abacacde”过滤结果为“abcde”*/void stringFilte原创 2013-09-29 09:53:10 · 598 阅读 · 0 评论 -
amixer 左右通道音量设置
#include #include int main(int argc, char **argv){ int iRightVol = 0; char ucCmdBuf[128] = {0}; int iLeftVol = 0; iLeftVol = atoi(argv[1]); iRightVol = atoi(argv[2]); p原创 2013-11-19 10:30:09 · 1031 阅读 · 0 评论 -
ubuntu下 curl-7.20.0 交叉编译
主机环境:[linux-devkit]:***dm365-dvsdk/dvsdk-demos_4_02_00_01/dm365/app/wifi_process> uname -aLinux ubuntu-desktop 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011 i686 GNU/Linux交叉编译原创 2013-11-27 14:07:36 · 563 阅读 · 0 评论 -
C stdio编译错误问题解决及去掉^M符号
错误:GNU C (Sourcery G++ Lite 2009q1-203) version 4.3.3 (arm-none-linux-gnueabi) compiled by GNU C version 4.3.2, GMP version 4.2.4, MPFR version 2.3.2.GGC heuristics: --param ggc-min-expand=原创 2013-11-27 10:29:20 · 714 阅读 · 0 评论 -
C 简单链表操作
#include #include #include /* 定义一个数字节点 */typedef struct tagStNode{int iData;struct tagStNode *pNext;}StNode;/* 创建iNum个节点,返回指向第一个节点的指针 */StNode* Create(int iNum);/* 打印 */void Print(StNode *pstHead);/*原创 2013-08-24 09:37:20 · 475 阅读 · 0 评论 -
Big-Endian 和 Little-Endian 判断
#include #include #include /* 程序输出 78 56 34 12,即采用小端存储 */static void show_bytes(unsigned char* pucStart, int iLen){ int i = 0; for (; i < iLen; i++) { printf("%.2x\n", *(pucStart + i)); }原创 2013-06-28 15:03:29 · 528 阅读 · 0 评论 -
数组元素首尾对调
#include #include #include void swap(int *iX, int *iY){ *iY = *iX ^ *iY; *iX = *iX ^ *iY; *iY = *iX ^ *iY;// printf("%3d, %3d\n", *iX, *iY);}int main(int argc, char **argv){ int aiArr原创 2013-06-28 18:01:11 · 1370 阅读 · 0 评论 -
strstr
原型:extern char *strstr(char *haystack, char *needle); 用法:#include 功能:从字符串haystack中寻找needle第一次出现的位置(不比较结束符NULL)。 说明:返回指向第一次出现needle位置的指针,如果没找到则返回NULL。原创 2011-11-26 10:48:16 · 142 阅读 · 0 评论 -
mount && umount
【 mount/umount系统调用】 功能描述: mount挂上文件系统,umount执行相反的操作。 用法: 1#include 2 3int mount(const char *source, const c原创 2011-11-26 10:23:02 · 461 阅读 · 0 评论 -
gdb 常用命令
list在第16行设置断点b 16在函数func处设置断点break func查看断点信息info break如果条件为真,则在指定行或函数处停止break line-or-function if condition在其他文件中设置断点break filename:line-numberbreak filename:function删除指定行的断原创 2012-04-12 15:24:58 · 358 阅读 · 0 评论 -
c static使用
转载:http://www.cnblogs.com/dc10101/archive/2007/08/22/865556.html在C语言中,static的字面意思很容易把我们导入歧途,其实它的作用有三条。(1)先来介绍它的第一条也是最重要的一条:隐藏。当我们同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性。为理解这句话,我举例来说明。我们要同时编译两个源转载 2012-04-22 16:26:51 · 386 阅读 · 0 评论 -
求数组中连续出现最多次数的数的次数
#include /** * 找出数组中出现次数哦最多的数的次数 */int MaxTimes(int *piArry, int iLen){ int iIdx = 1; /* 数组索引 */ int iCount = 1; /* */ int iMaxNum = 1; /* 出现的最大次数 */ while (iIdx <= iLen) { /* 如果相原创 2013-06-15 16:40:29 · 1027 阅读 · 1 评论 -
两个含有n个元素的有序整形数组a和b(数组a和b中没有重复元素),求他们的交集。
#include /** * 两个含有n个元素的有序整形数组a和b(数组a和b中没有重复元素),求他们的交集, *//* 找出两个有序数组的交集 */int PrintMixed(int *piArryA, int iLenA, int *piArryB, int iLenB){ int iIdxA = 0; /* piArryA数组索引 */ int iIdxB = 0; /原创 2013-06-15 17:01:12 · 1617 阅读 · 0 评论 -
字符串转换为整数
输入一个表示整数的字符串,把该字符串转换成整数并输出,例如输入字符串"345",则输出整数345。请完成函数StrToInt,实现字符串转换成整数的功能。#include #include #include static int strToInt(char *pcStr){ int iIdx = 0; int iTmp = 0; int iLen = 0; asse原创 2013-06-18 23:05:06 · 438 阅读 · 0 评论 -
整数翻转
#include #include #include #include /* 返回该数一共有多少位 */static int getDigitNum(int iNum){ int iCount = 0; assert(iNum > 0); while (iNum > 0) { iNum = iNum / 10 ; iCount++ ; } return iCo原创 2013-06-18 22:36:05 · 683 阅读 · 0 评论 -
C 数组和指针
1、用a[i] 这样的形式对数组进行访问,总是被编译器“改写”或解释为想*(a + 1)这样的指针访问。2、指针始终就是指针。它绝不可以改写成数组。你可以用下标形式访问指针。一般都是指针作为函数参数时,而且你知道实际传递给函数的是一个数组。3、在函数参数的声明中,数组名被编译器当做指向该数组第一个元素的指针。即作为函数参数的数组始终会被编译器修改成为指向数组第一个元素的指针原创 2013-06-21 21:49:22 · 422 阅读 · 0 评论 -
Linux i2c 读写应用程序
/* This software uses a BSD license.Copyright (c) 2010, Sean Cross / chumby industriesAll rights reserved. Redistribution and use in source and binary forms, with or without modification, are原创 2013-12-14 19:15:26 · 5884 阅读 · 1 评论