易截截图软件、单文件、免安装、纯绿色、仅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分
}


相关文档:

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

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

C#(C sharp)字符串和时间的相互转换

C#(C sharp)字符串和时间的相互转换。
 
一、DateTime –> string
时间类型转化成字符串类型,那是相当的简单,直接调用ToString()方法即可。如:
DateTime dt = DateTime.Now;
string dtStr = dt.ToString();
 
如果想对输出格式化,可以这么写:
dt.ToString("yyyy年MM月dd日");   ......

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

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

C/C++中的文件操作

1.fopen()
  fopen的原型是:FILE *fopen(const char *filename,const char *mode),fopen实现三个功能
为使用而打开一个流 
把一个文件和此流相连接 
给此流返回一个FILE指针
参数filename指向要打开的文件名,mode表示打开状态的字符串,其取值如下表
字符串 含义 
"r" 以只读方式打开文件  ......

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号