易截截图软件、单文件、免安装、纯绿色、仅160KB

c 字符串处理

程序开头要声明
#include <string.h>
 
函数名: stpcpy
功 能: 拷贝一个字符串到另一个
用 法: char *stpcpy(char *destin, char *source);
程序例:
 
#include <stdio.h>
#include <string.h>
 
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
 
stpcpy(string, str1);
printf("%s\n", string);
return 0;
}
 
 
 
 
函数名: strcat
功 能: 字符串拼接函数
用 法: char *strcat(char *destin, char *source);
程序例:
 
#include <string.h>
#include <stdio.h>
 
int main(void)
{
char destination[25];
char *blank = " ", *c = "C++", *Borland = "Borland";
 
strcpy(destination, Borland);
strcat(destination, blank);
strcat(destination, c);
 
printf("%s\n", destination);
return 0;
}
 
 
 
 
函数名: strchr
功 能: 在一个串中查找给定字符的第一个匹配之处\
用 法: char *strchr(char *str, char c);
程序例:
 
#include <string.h>
#include <stdio.h>
 
int main(void)
{
char string[15];
char *ptr, c = 'r';
 
strcpy(string, "This is a string");
ptr = strchr(string, c);
if (ptr)
printf("The character %c is at position: %d\n", c, ptr-string);
else
printf("The character was not found\n");
return 0;
}
 
 
 
 
函数名: strcmp
功 能: 串比较
用 法: int strcmp(char *str1, char *str2);
看Asic码,str1>str2,返回值 > 0;两串相等,返回0
程序例:
 
#include <string.h>
#include <stdio.h>
 
int main(void)
{
char *buf1 = "aaa", *buf2 = "bbb", *buf3 = "ccc";
int ptr;
 
ptr = strcmp(buf2, buf1);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
else
printf("buffer 2 is less than buffer 1\n");
 
ptr = strcmp(buf2, buf3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 3\n");
else


相关文档:

C图形函数解析

C语言中,图形函数大致可分为两类:字符模式函数和图形模式函数。本节我们练习使用字符模式函数。  
          使用字符模式函数应该在程序中联入conio.h头部文件。  
          下面是一些函数的作用  
  1)     void   &nbs ......

C专家编程精编之一

C专家编程  精编之一     第一章~第三章
C的复杂之处 在于它的指针 ,但是比其指针更为复杂的是它的声明 !!!
你能看懂它们的意思 吗?
apple=sizeof(int)*p  ;   apple=sizeof * p;
j= (char (*)[20])malloc(20);
int   const * grape; 与   int * const gr ......

Linux下的C编程实战之文件系统编程

文章来源:http://dev.yesky.com/468/7601968.shtml
2007-10-12 11:01作者:宋宝华出处:天极网软件频道责任编辑:方舟
1.Linux文件系统
  Linux支持多种文件系统,如ext、ext2、minix、iso9660、msdos、fat、vfat、nfs等。在这些具体文件系统的上层,Linux提供了虚拟文件系统(VFS)来统一它们的行为,虚拟文件系统为 ......

My emacs color theme for c and c++

在这儿下载:color-theme
:
http://download.savannah.gnu.org/releases-noredirect/color-theme/
wget http://download.savannah.gnu.org/releases-noredirect/color-theme/color-theme-6.6.0.tar.gz
tar zxf color-theme-6.6.0.tar.gz -C ~/.emacs.d
在.emacs中加入下列语句:
;; corlor-theme ......

给C盘减减肥,让你电脑飞一般速度

当你买了台新电脑时,觉得性能,速度,你都比较满意,但是随着时间推移,你觉得你C盘空间越来越小,速度也降下了,那我们该怎么办呢?
     对于菜鸟来说,有一点你必须注意:当你下载东西,有些网站是默认C盘,这时可以选择下载盘时,最好放在其他盘里,不可以选择也没办法,C盘里的文件也是病毒喜欢 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号