易截截图软件、单文件、免安装、纯绿色、仅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代码:电话号码和字母转换

这两天看到有人讨论电话键盘上的字母、号码和字母的转换,我也随便写了一段
#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语言编程基础(Makefile)

 
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 ......

LINUX C中用define定义可变参数的宏

  一般在调试打印Debug信息的时候, 需要可变参数的宏. 从C99开始可以使编译器标准支持可变参数宏(variadic macros), 另外GCC也支持可变参数宏, 但是两种在细节上可能存在区别.
1. __VA_ARGS__
        __VA_ARGS__ 将 "..." 传递给宏 . 如
     ......

C\C++关于string.h头文件和string类

 学习C语言时,用字符串的函数例如stpcpy()、strcat()、strcmp()等,要包含头文件string.h
学习C++后,C++有字符串的标准类string,string类也有很多方法,用string类时要用到string.h头文件。
我现在看vc的书上也有CString类,这个要包含什么,怎么用?
我现在很迷惑,这两个 string.h有什么区别。是怎么回事
且看 ......

Eclipse对C/C++的支持比Netbeans好多了

Netbeans经常会出现写代码的时候代码提示出不来的情况,甚至是代码根本没错,编译都能通过,但是代码帮助就提示我说我有错误,在下面画条红线!而这些问题Eclipse没有出现过!而且Eclipse有专门的CDT插件开发小组,很好强大。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号