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分
}
相关文档:
Linux下C语言编程基础(Makefile)
2005-01-18 10:28:23 来自:赛迪网
假设我们有下面这样的一个程序,源代码如下:
/* main.c */
#include "mytool1.h"
#include "mytool2.h"
int main(int argc,char **argv)
{
mytool1_print("hello");
mytool2_print(&q ......
有谁真正的理解过一个编译器呢?许多人认为TC很简单很落后,但是即便是这样简单的工具,到底有几个人真正的深入理解了呢?一个简单的编译器都不能理解,如何能成为高手,如何能深入的使用更加高级的工具呢?不要以为自己使用的是VC就很了不起,因为使用这样傻瓜化的工具只能让你看不到事物的本质。接下来我们就来深入的认 ......
C/C++中Static的作用详述
一.在C语言中,static的字面意思很容易把我们导入歧途,其实它的作用有三条。
(1)先来介绍它的第一条也是最重要的一条:隐藏。
当我们同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性。为理解这句话,我举例来说明。我们要同时编译两个源文件,一个是a.c,另一个是m ......
定义按值传递和按引用传递这两个术语是重要的。
按值传递意味着当将一个参数传递给一个函数时,函数接收的是参数的一个副本。因此,如 果函数修改了该参数,仅改变副本,而原始值保持不变。按引用传递意味着当将一个参数传递给一个函数时,函数接收的是参数的内存地址,而不是参数的副本。因 此,如果函数修改了该参数,调 ......