C测试小程序
C测试小程序
1、 字符串类
1.1 strstr
功能:查找和获取子串
void test_strstr()
{
char *str="Borland International";
char *str1="B",*ptr1;
char *str2="na",*ptr2;
char *str3="",*ptr3;
ptr1=strstr(str,str1);
printf("The substring1 is: %s\n", ptr1);//Borland International
ptr2=strstr(str,str2);
printf("The substring2 is: %s\n", ptr2);//national
ptr3=strstr(str,str3);
printf("The substring3 is: %s\n", ptr3); //Borland International
}
/*****************************************************
char *strstr( const char *string, const char *strCharSet );
Each of these functions returns a pointer to the first occurrence of strCharSet in string,
or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length,
the function returns string.
******************************************************/
1.2 atoi和_itoa
功能:char和int之间的互相转换
void char2int_1()
{
char* temp1="123";
int a1=atoi(temp1);
printf("char2int_1()\ta1+1=%
相关文档:
C和C++互相调用函数时,使用extern "C"。
原因:
C不支持函数重载,而C++支持函数重载。函数被C++编译后会名字与C语言不同。假设某函数原型为foo(ing x, int y),被C++编译后名字为_foo_int_int,而C编译器编译后名字为_foo。 ......
利用c.vim插件,你可以实现
添加文件头
添加注释
插入一些代码片段
语法检查
读函数文档
注释代码块
这一插件的作者是 Fritz Mehner, 目标就是打造程序员流畅的编辑环境。
这一插件还能完成:
Statement oriented editing of C / C++ programs
Speed up writing new code considerably.
Write code and ......
这几天我安装了一个Linux系统,想在里面学一下C语言的编写,发现在里面运行有一个好奇怪的现象:如下面
#include<stdio.h>
void mian(){
printf("hello world!");
}
输出没有结果!搞的我看了半天,程序没有错误啊!怎么这样!后来我把程序改为
#include<stdio.h>
void mian(){
printf("hello ......
Turbo C 2.0 函数中文说明大全
分类函数,所在函数库为ctype.h
int isalpha(int ch) 若ch是字母('A'-'Z','a'-'z')返回非0值,否则返回0
int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或数字('0'-'9'),返回非0值,否则返回0
int isascii(int ch) 若ch是字符(ASCII码中的0-127)返回非0值,否则返回0
int iscntrl(int ......