易截截图软件、单文件、免安装、纯绿色、仅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字符串处理函数的实现(Linux)
#include <stddef.h>
char * ___strtok = NULL;
char * strcpy(char * dest,const char *src)
{
char *tmp = dest;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}
char * strncpy(char * dest,const char *src,size_t count)
{
char *tmp = d ......

C图形函数解析

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

使用 gperf 实现高效的 C/C++ 命令行处理


使用 gperf 实现高效的 C/C++ 命令行处理
GNU 完美(gperf)散列函数生成器简化复杂的输入字符串
文档选项
级别: 中级
Arpan Sen
(arpan@syncad.com
), 技术主管, Synapti Computer Aided Design Pvt Ltd
2007 年 9 月 10 日
GNU 的 gperf 工具是一种 “完美的” 散列函数,可以为用户提供的一组特 ......

ARM中C和汇编混合编程及示例

1. 在C语言中内嵌汇编
在C中内嵌的汇编指令包含大部分的ARM和Thumb指令,不过其使用与汇编文件中的指令有些不同,存在一些限制,主要有下面几个方面:
 
a. 不能直接向PC寄存器赋值,程序跳转要使用B或者BL指令
b. 在使用物理寄存器时,不要使用过于复杂的C表达式,避免物理寄存器冲突
c. R12和R13可能被编译 ......

C专家编程精编之一

C专家编程  精编之一     第一章~第三章
C的复杂之处 在于它的指针 ,但是比其指针更为复杂的是它的声明 !!!
你能看懂它们的意思 吗?
apple=sizeof(int)*p  ;   apple=sizeof * p;
j= (char (*)[20])malloc(20);
int   const * grape; 与   int * const gr ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号