- 浏览: 223073 次
- 性别:
- 来自: 南京
文章分类
最新评论
-
ranguisheng:
沙漏的问题貌似可以抽象为一个编程问题,(上7,下0)-(上4, ...
MicroStrategy的面经(from bbs.byr.. -
wss71104307:
米牛牛 写道谢谢!另外关于最后一段的证明、是否可以将【前i个元 ...
Reservoir Sampling -
米牛牛:
谢谢!另外关于最后一段的证明、是否可以将【前i个元素】改为【池 ...
Reservoir Sampling -
javaDevil:
引用self.parent.tb_show(t,a,g); ...
thickbox跨越frameset -
wangyazhen:
这样写似乎不大好,比普通的js要简洁,但是通用性还是差了点,建 ...
Jquery 表单验证
函数名: strcpy
功 能: 拷贝一个字符串到另一个字符串
用 法: char *strcpy(char *destin, char *source);
程序例:
#i nclude <stdio.h> #i nclude <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);
程序例:
#i nclude <string.h> #i nclude <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);
程序例:
#i nclude <string.h> #i nclude <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程序例:
#i nclude <string.h> #i nclude <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 printf("buffer 2 is less than buffer 3\n"); return 0; }
函数名: strncmpi
功 能: 将一个串中的一部分与另一个串比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2, unsigned maxlen);
程序例:
#i nclude <string.h> #i nclude <stdio.h> int main(void) { char *buf1 = "BBB", *buf2 = "bbb"; int ptr; ptr = strcmpi(buf2, buf1); if (ptr > 0) printf("buffer 2 is greater than buffer 1\n"); if (ptr < 0) printf("buffer 2 is less than buffer 1\n"); if (ptr == 0) printf("buffer 2 equals buffer 1\n"); return 0; }
函数名: strcpy
功 能: 串拷贝
用 法: char *strcpy(char *str1, char *str2);
程序例:
#i nclude <stdio.h> #i nclude <string.h> int main(void) { char string[10]; char *str1 = "abcdefghi"; strcpy(string, str1); printf("%s\n", string); return 0; }
函数名: strcspn
功 能: 在串中查找第一个给定字符集内容的段
用 法: int strcspn(char *str1, char *str2);
程序例:
#i nclude <stdio.h> #i nclude <string.h> #i nclude <alloc.h> int main(void) { char *string1 = "1234567890"; char *string2 = "747DC8"; int length; length = strcspn(string1, string2); printf("Character where strings intersect is at position %d\n", length); return 0; }
函数名: strdup
功 能: 将串拷贝到新建的位置处
用 法: char *strdup(char *str);
程序例:
#i nclude <stdio.h> #i nclude <string.h> #i nclude <alloc.h> int main(void) { char *dup_str, *string = "abcde"; dup_str = strdup(string); printf("%s\n", dup_str); free(dup_str); return 0; }
函数名: stricmp
功 能: 以大小写不敏感方式比较两个串
用 法: int stricmp(char *str1, char *str2);
程序例:
#i nclude <string.h> #i nclude <stdio.h> int main(void) { char *buf1 = "BBB", *buf2 = "bbb"; int ptr; ptr = stricmp(buf2, buf1); if (ptr > 0) printf("buffer 2 is greater than buffer 1\n"); if (ptr < 0) printf("buffer 2 is less than buffer 1\n"); if (ptr == 0) printf("buffer 2 equals buffer 1\n"); return 0; }
函数名: strerror
功 能: 返回指向错误信息字符串的指针
用 法: char *strerror(int errnum);
程序例:
#i nclude <stdio.h> #i nclude <errno.h> int main(void) { char *buffer; buffer = strerror(errno); printf("Error: %s\n", buffer); return 0; }
函数名: strcmpi
功 能: 将一个串与另一个比较, 不管大小写
用 法: int strcmpi(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = strcmpi(buf2, buf1);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0; }
函数名: strncmp
功 能: 串比较
用 法: int strncmp(char *str1, char *str2, int maxlen);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc";
int ptr;
ptr = strncmp(buf2,buf1,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
else
printf("buffer 2 is less than buffer 1\n");
ptr = strncmp(buf2,buf3,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 3\n");
else
printf("buffer 2 is less than buffer 3\n");
return(0);
}
函数名: strncmpi
功 能: 把串中的一部分与另一串中的一部分比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strncmpi(buf2,buf1,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strncpy
功 能: 串拷贝
用 法: char *strncpy(char *destin, char *source, int maxlen);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
strncpy(string, str1, 3);
string[3] = '\0';
printf("%s\n", string);
return 0;
}
函数名: strnicmp
功 能: 不注重大小写地比较两个串
用 法: int strnicmp(char *str1, char *str2, unsigned maxlen);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strnicmp(buf2, buf1, 3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strnset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strnset(char *str, char ch, unsigned n);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %s\n", string);
strnset(string, letter, 13);
printf("string after strnset: %s\n", string);
return 0;
}
函数名: strpbrk
功 能: 在串中查找给定字符集中的字符
用 法: char *strpbrk(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string1 = "abcdefghijklmnopqrstuvwxyz";
char *string2 = "onm";
char *ptr;
ptr = strpbrk(string1, string2);
if (ptr)
printf("strpbrk found first character: %c\n", *ptr);
else
printf("strpbrk didn't find character in set\n");
return 0;
}
函数名: strrchr
功 能: 在串中查找指定字符的最后一个出现
用 法: char *strrchr(char *str, char c);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char string[15];
char *ptr, c = 'r';
strcpy(string, "This is a string");
ptr = strrchr(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;
}
函数名: strrev
功 能: 串倒转
用 法: char *strrev(char *str);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *forward = "string";
printf("Before strrev(): %s\n", forward);
strrev(forward);
printf("After strrev(): %s\n", forward);
return 0;
}
函数名: strset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strset(char *str, char c);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void) {
char string[10] = "123456789";
char symbol = 'c';
printf("Before strset(): %s\n", string);
strset(string, symbol);
printf("After strset(): %s\n", string);
return 0;
}
函数名: strspn
功 能: 在串中查找指定字符集的子集的第一次出现
用 法: int strspn(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
#i nclude <alloc.h>
int main(void)
{
char *string1 = "1234567890";
char *string2 = "123DC8";
int length;
length = strspn(string1, string2);
printf("Character where strings differ is at position %d\n", length);
return 0;
}
函数名: strstr
功 能: 在串中查找指定字符串的第一次出现
用 法: char *strstr(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0; }
函数名: strtod
功 能: 将字符串转换为double型值
用 法: double strtod(char *str, char **endptr);
程序例:
#i nclude <stdio.h>
#i nclude <stdlib.h>
int main(void)
{
char input[80], *endptr;
double ;
printf("Enter a floating point number:");
gets(input);
= strtod(input, &endptr);
printf("The string is %s the number is %lf\n", input, );
return 0;
}
函数名: strtok
功 能: 查找由在第二个串中指定的分界符分隔开的单词
用 法: char *strtok(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char input[16] = "abc,d";
char *p;
/* strtok places a NULL terminator in front of the token, if found */
p = strtok(input, ",");
if (p)
printf("%s\n", p);
/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token
*/
p = strtok(NULL, ",");
if (p)
printf("%s\n", p);
return 0;
}
函数名: strtol
功 能: 将串转换为长整数
用 法: long strtol(char *str, char **endptr, int base);
程序例:
#i nclude <stdlib.h>
#i nclude <stdio.h>
int main(void)
{
char *string = "87654321", *endptr;
long lnumber;
/* strtol converts string to long integer */
lnumber = strtol(string, &endptr, 10);
printf("string = %s long = %ld\n", string, lnumber);
return 0;
}
函数名: strupr
功 能: 将串中的小写字母转换为大写字母
用 法: char *strupr(char *str);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz", *ptr;
/* converts string to upper case characters */
ptr = strupr(string); printf("%s\n", ptr);
return 0;
}
函数名: swab
功 能: 交换字节
用 法: void swab (char *from, char *to, int nbytes);
程序例:
#i nclude <stdlib.h>
#i nclude <stdio.h>
#i nclude <string.h>
char source[15] = "rFna koBlrna d"; char target[15];
int main(void) {
swab(source, target, strlen(source));
printf("This is target: %s\n", target);
return 0;
} 函数名: strcpy
功 能: 拷贝一个字符串到另一个字符串
用 法: char *strcpy(char *destin, char *source);
程序例:
#i nclude <stdio.h>
#i nclude <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);
程序例:
#i nclude <string.h>
#i nclude <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);
程序例:
#i nclude <string.h> #i nclude <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程序例:
#i nclude <string.h>
#i nclude <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
printf("buffer 2 is less than buffer 3\n");
return 0;
}
函数名: strncmpi
功 能: 将一个串中的一部分与另一个串比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2, unsigned maxlen);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = strcmpi(buf2, buf1);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strcpy
功 能: 串拷贝
用 法: char *strcpy(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
strcpy(string, str1);
printf("%s\n", string);
return 0;
}
函数名: strcspn
功 能: 在串中查找第一个给定字符集内容的段
用 法: int strcspn(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
#i nclude <alloc.h>
int main(void) {
char *string1 = "1234567890";
char *string2 = "747DC8";
int length;
length = strcspn(string1, string2);
printf("Character where strings intersect is at position %d\n", length);
return 0;
}
函数名: strdup
功 能: 将串拷贝到新建的位置处
用 法: char *strdup(char *str);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
#i nclude <alloc.h>
int main(void)
{
char *dup_str, *string = "abcde";
dup_str = strdup(string);
printf("%s\n", dup_str);
free(dup_str);
return 0;
}
函数名: stricmp
功 能: 以大小写不敏感方式比较两个串
用 法: int stricmp(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = stricmp(buf2, buf1);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strerror
功 能: 返回指向错误信息字符串的指针
用 法: char *strerror(int errnum);
程序例:
#i nclude <stdio.h>
#i nclude <errno.h>
int main(void)
{
char *buffer;
buffer = strerror(errno);
printf("Error: %s\n", buffer);
return 0;
}
函数名: strcmpi
功 能: 将一个串与另一个比较, 不管大小写
用 法: int strcmpi(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = strcmpi(buf2, buf1);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0; }
函数名: strncmp
功 能: 串比较
用 法: int strncmp(char *str1, char *str2, int maxlen);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc";
int ptr;
ptr = strncmp(buf2,buf1,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
else
printf("buffer 2 is less than buffer 1\n");
ptr = strncmp(buf2,buf3,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 3\n");
else
printf("buffer 2 is less than buffer 3\n");
return(0);
}
函数名: strncmpi
功 能: 把串中的一部分与另一串中的一部分比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strncmpi(buf2,buf1,3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strncpy
功 能: 串拷贝
用 法: char *strncpy(char *destin, char *source, int maxlen);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
strncpy(string, str1, 3);
string[3] = '\0';
printf("%s\n", string);
return 0;
}
函数名: strnicmp
功 能: 不注重大小写地比较两个串
用 法: int strnicmp(char *str1, char *str2, unsigned maxlen);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strnicmp(buf2, buf1, 3);
if (ptr > 0)
printf("buffer 2 is greater than buffer 1\n");
if (ptr < 0)
printf("buffer 2 is less than buffer 1\n");
if (ptr == 0)
printf("buffer 2 equals buffer 1\n");
return 0;
}
函数名: strnset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strnset(char *str, char ch, unsigned n);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %s\n", string);
strnset(string, letter, 13);
printf("string after strnset: %s\n", string);
return 0;
}
函数名: strpbrk
功 能: 在串中查找给定字符集中的字符
用 法: char *strpbrk(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string1 = "abcdefghijklmnopqrstuvwxyz";
char *string2 = "onm";
char *ptr;
ptr = strpbrk(string1, string2);
if (ptr)
printf("strpbrk found first character: %c\n", *ptr);
else
printf("strpbrk didn't find character in set\n");
return 0;
}
函数名: strrchr
功 能: 在串中查找指定字符的最后一个出现
用 法: char *strrchr(char *str, char c);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char string[15];
char *ptr, c = 'r';
strcpy(string, "This is a string");
ptr = strrchr(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;
}
函数名: strrev
功 能: 串倒转
用 法: char *strrev(char *str);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char *forward = "string";
printf("Before strrev(): %s\n", forward);
strrev(forward);
printf("After strrev(): %s\n", forward);
return 0;
}
函数名: strset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strset(char *str, char c);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void) {
char string[10] = "123456789";
char symbol = 'c';
printf("Before strset(): %s\n", string);
strset(string, symbol);
printf("After strset(): %s\n", string);
return 0;
}
函数名: strspn
功 能: 在串中查找指定字符集的子集的第一次出现
用 法: int strspn(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
#i nclude <alloc.h>
int main(void)
{
char *string1 = "1234567890";
char *string2 = "123DC8";
int length;
length = strspn(string1, string2);
printf("Character where strings differ is at position %d\n", length);
return 0;
}
函数名: strstr
功 能: 在串中查找指定字符串的第一次出现
用 法: char *strstr(char *str1, char *str2);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0; }
函数名: strtod
功 能: 将字符串转换为double型值
用 法: double strtod(char *str, char **endptr);
程序例:
#i nclude <stdio.h>
#i nclude <stdlib.h>
int main(void)
{
char input[80], *endptr;
double ;
printf("Enter a floating point number:");
gets(input);
= strtod(input, &endptr);
printf("The string is %s the number is %lf\n", input, );
return 0;
}
函数名: strtok
功 能: 查找由在第二个串中指定的分界符分隔开的单词
用 法: char *strtok(char *str1, char *str2);
程序例:
#i nclude <string.h>
#i nclude <stdio.h>
int main(void)
{
char input[16] = "abc,d";
char *p;
/* strtok places a NULL terminator in front of the token, if found */
p = strtok(input, ",");
if (p)
printf("%s\n", p);
/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token
*/
p = strtok(NULL, ",");
if (p)
printf("%s\n", p);
return 0;
}
函数名: strtol
功 能: 将串转换为长整数
用 法: long strtol(char *str, char **endptr, int base);
程序例:
#i nclude <stdlib.h>
#i nclude <stdio.h>
int main(void)
{
char *string = "87654321", *endptr;
long lnumber;
/* strtol converts string to long integer */
lnumber = strtol(string, &endptr, 10);
printf("string = %s long = %ld\n", string, lnumber);
return 0;
}
函数名: strupr
功 能: 将串中的小写字母转换为大写字母
用 法: char *strupr(char *str);
程序例:
#i nclude <stdio.h>
#i nclude <string.h>
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz", *ptr;
/* converts string to upper case characters */
ptr = strupr(string); printf("%s\n", ptr);
return 0;
}
函数名: swab
功 能: 交换字节
用 法: void swab (char *from, char *to, int nbytes);
程序例:
#i nclude <stdlib.h>
#i nclude <stdio.h>
#i nclude <string.h>
char source[15] = "rFna koBlrna d"; char target[15];
int main(void) {
swab(source, target, strlen(source));
printf("This is target: %s\n", target);
return 0;
}
发表评论
-
char * 与 char []
2009-12-15 20:46 1030There is an important differenc ... -
getKey
2009-06-30 21:31 953#include <iostream> #inc ... -
读书笔记,(杂)
2009-06-02 22:45 947引用与指针的区别: 1. 引用必须被初始化。指针可以不初 ... -
strlen与sizeof的区别
2009-05-26 09:44 1863strlen与sizeof的区别 1.siz ... -
读“虚函数在对象中的内存布局”
2009-05-04 20:11 900http://blog.sina.com.cn/s/blog_ ... -
memcpy memmove 区别
2009-04-19 15:43 1927memcpy 和memmove 都是把一个内存块拷贝到另一个内 ... -
浮点型(float,double)判断是否为0
2009-04-03 12:09 11771无论float 还是double 都有精度 限制,故当浮点型数 ... -
scanf sscanf的用法
2008-12-26 11:06 1825sscanf http://baike.baidu.com/v ... -
memcopy 和memmove
2008-12-21 14:29 27371.memmove 函数原型:void ... -
%f 与 %lf的区别
2008-12-21 11:59 3002%f是单精度浮点型,输出的时候要满足6位小数。 %lf ... -
qsort的七种排序
2008-12-20 19:17 1085七种 qsort 排序方法 < 本文中排 ... -
在北邮 bbs上看到一个理解指针,指针数组不错的题目
2008-10-27 20:29 1071#include <stdio.h> int m ... -
从字符串s1 中删除所有在s2里出现的字符 squeeze
2008-10-22 16:40 1736Write a alternate version of sq ... -
自己写strcat函数,有点小问题
2008-10-22 15:53 1205reading the book of 《the C prog ... -
Convert a String of hexademical digits into a Int
2008-10-22 13:47 1124<<The C programming langu ... -
Reading The C Programing Language-Counting words
2008-10-18 20:35 1029A simple Programing: Couting th ... -
Note: EOF The C programming language,
2008-10-18 16:39 1022Reading <<The C programmi ... -
字符数组
2008-10-16 12:47 876看下段代码输出结果 #include<iostream. ...
相关推荐
接下来详细说明标题和描述中提及的C语言字符串操作函数。 首先,`strcpy` 函数的用途是将源字符串 `source` 完整拷贝到目标字符串 `destin` 中,并且包括源字符串的终止符 '\0'。这个函数不会检查目标数组是否有...
本资源"《C语言字符串练习(习题+答案).zip》"正是针对这一需求而准备的,它包含了C语言字符串操作的专项练习题和对应的答案,帮助学习者巩固和提升在字符串处理方面的技能。 字符串在C语言中扮演着重要角色,它们...
以下是一些常见的C语言字符串函数及其详细说明: 1. **stpcpy()**: 此函数用于将一个字符串复制到另一个字符串中,并返回目标字符串的终止符位置。其函数原型为`char *stpcpy(char *destin, char *source)`。在提供...
纯C语言实现字符串拆分操作,把字符串拆分成字符串数组,然后再输出。 使用sstream方法,作为底层驱动操作实现非常方便。
根据给定的信息,本文将详细解释两个用于C语言中字符串截取的方法:`subStringByIndex` 和 `subStringByPointer`。这两个函数都属于自定义实现,它们提供了灵活且实用的功能来...这对于处理复杂的字符串操作非常有用。
以上就是C语言字符串快速压缩算法的实现细节。这个算法体现了C语言中对字符串的基本操作,包括字符数组的使用、字符串函数(如`strlen`)的调用以及自定义字符串处理逻辑。同时,它也展示了如何处理多种情况和数据...
C语言字符串操作的8个库函数源代码 1.strcpy.c 2.strcat.c 3.strlen.c 4.Insstr.c 5.substr.c 6.strstr.c 7.delstr.c 8.strcmp.c
C语言字符串操作 C语言提供了许多用来处理字符串的标准库函数,本章将介绍其中的一部分函数。在编写C程序时,经常要用到处理字符串的技巧,本章提供的例子将帮助您快速学会一些常用函数的使用方法,其中的许多...
C语言中,字符的操作有多种方法,这里主要是特有的字符串库函数进行操作,简化编程过程,增强学生对字符串及字符操作的理解。
"C语言字符串操作库函数详解" 在C语言中,字符串操作是非常重要的一部分,包括字符串的创建、连接、拷贝、比较等等。下面我们将详细介绍如何使用C语言实现字符串操作的库函数。 1. 字符串长度计算 在C语言中,...
C语言字符串函数使用大全 C语言字符串函数是C语言中用于操作字符串的函数,包括字符串拷贝、字符串拼接、字符串查找、字符串比较等。这些函数在C语言编程中非常重要,本文将对这些函数进行详细的介绍。 1. stpcpy...
### 各种C语言字符串函数-笔试面试必备 在C语言中,字符串处理是程序员必须掌握的基本技能之一,尤其在笔试和面试环节中,考察字符串函数的使用与自定义实现非常常见。以下是对几种常见的C语言字符串函数的深入解析...
C语言字符串操作函数 C语言字符串操作函数是一组强大且实用的函数,用于处理和操作字符串。这些函数在C语言编程中非常常用,掌握这些函数可以提高编程效率和质量。本章将详细介绍C语言字符串操作函数的使用方法和...
在C语言中,字符串其实是由字符组成的数组,但由于其特殊性,经常被单独讨论。由于C语言并没有专门的字符串类型,我们通常使用字符数组来表示字符串。然而,指针是C语言中非常重要的一个概念,它能指向内存中的任何...
标题 "C语言字符串数字提出.zip" 涉及的核心知识点是C语言中处理字符串和提取数字的方法。在C语言中,字符串是由字符组成的数组,而从字符串中提取数字则需要运用到字符串处理函数和数值转换函数。下面我们将深入...
C语言字符串处理函数整理版本,包含字符串基本操作,字符串类型转换、字符检查、输入输出流、输入输出流分割、异常处理等