易截截图软件、单文件、免安装、纯绿色、仅160KB

C常用函数

检查空格字符
#include <ctype.h>
int isspace ( int c );
http://www.cplusplus.com/reference/clibrary/cctype/isspace/
Checks if parameter c is a white-space character.For the purpose of this function, standard white-space characters are:
' '
(0x20)
space (SPC)
'\t'
(0x09)
horizontal tab (TAB)
'\n'
(0x0a)
newline (LF)
'\v'
(0x0b)
vertical tab (VT)
'\f'
(0x0c)
feed (FF)
'\r'
(0x0d)
carriage return (CR)
 /* isspace example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
int c;
int i=0;
char str[]="Example sentence to test isspace\n";
while (str[i])
{
c=str[i];
if (isspace(c)) c='\n';
putchar (c);
i++;
}
return 0;
}

/*
This code prints out the C string character by character, replacing any white-space character by a newline character. Output:

Example
sentence
to
test
isspace
*/


memcpy实现:
char *strcpy(char *strDest, const char *strSrc){
assert((strDest!=NULL) && (strSrc !=NULL)); // 2分
char *address = strDest; // 2分
while( (*strDest++ = * strSrc++) != '\0' ) // 2分
NULL ;
return address ; // 2分
}


相关文档:

(转)C/C++ 宏详解

众多C++书籍都忠告我们C语言宏是万恶之首,但事情总不如我们想象的那么坏,就如同goto一样。宏有
一个很大的作用,就是自动为我们产生代码。如果说模板可以为我们产生各种型别的代码(型别替换),
那么宏其实可以为我们在符号上产生新的代码(即符号替换、增加)。
关于宏的一些语法问题,可以在google上找到。相信我,你对 ......

Linux下 c 判断一个文件是否存在

#include <stdio.h>
#include <unistd.h>
#define FOO "foo"
int main(void)
{
if(!access(FOO, F_OK))
{
if(!unlink(FOO))
{

}
else
{
printf("remove %s failed\n", FOO);
}
}
else
{
printf("%s not existed\ ......

c代码:电话号码和字母转换

这两天看到有人讨论电话键盘上的字母、号码和字母的转换,我也随便写了一段
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_LEN 15
char *tbl_itoa[] =
{
"0", // 0
"1", // 1
"ABC", // 2
"DEF", // 3
"GHI", // 4
"JKL", // 5
"MNO", ......

[转贴]linux下c语言嵌入汇编

 网上看到的这篇关于Linux下C语言嵌入汇编的文章写的非常全,转载过来。
Using Assembly Language in Linux.
Intel和AT&T汇编语法差异:
1。前缀:
Intel汇编寄存器和立即数无需前缀。后者寄存器前缀为%,立即数前缀为$。
eg:
   Intex Syntax
   mov eax,1
   mov ebx,0f ......

C深度解剖问题代码分析笔记1

#include <stdio.h>
int main()
{
int a[5]={1,2,3,4,5};
int *ptr1=(int*)(&a+1);
int *ptr2=(int*)((int)a+1);
printf("%p,%x,%p\n",(int)a,*(ptr2+1),ptr1);//(int*)(&a));
printf("%d\n",(int*)(&a-16));
printf("%d,%x\n",ptr1[-1] ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号