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分
}
相关文档:
#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文件中,而*.h文件中声明变量或函数名和符号名.
避面重复编译的解决方法:
比如你有两个C文件,这两个C文件都include了同一个头文件。而编译时,这两个C文件都要调用同一个头文件去编译,重复编译会产生大量的声明冲突。解决这个问题的方法使用#ifndef, #endif, #endif。
&nbs ......
网上看到的这篇关于Linux下C语言嵌入汇编的文章写的非常全,转载过来。
Using Assembly Language in Linux.
Intel和AT&T汇编语法差异:
1。前缀:
Intel汇编寄存器和立即数无需前缀。后者寄存器前缀为%,立即数前缀为$。
eg:
Intex Syntax
mov eax,1
mov ebx,0f ......