有一定的难度,作者只做了前三题!
题目请见 http://download.csdn.net/download/wangpegasus/5701765
1、
char *find_char(char const *source, char const *chars)
{
char *ptr;
if(source != NULL && chars != NULL)
{
for (; *source != '\0'; source++)
{
for (ptr = (char *) chars; *ptr != '\0'; ptr++)
{
if (*ptr = * source)
{
return (char *)source;
}
}
}
}
return NULL;
}
2、
char *match(char *string, char *sub)
{
while (*sub != '\0')
{
string++;
sub++;
if (*string != *sub)
{
return NULL;
}
}
return string;
}
int del_substr( char * str, char const *substr)
{
char * ptr;
ptr = NULL;
if ( str == NULL && substr == NULL)
{
return 0;
}
for (; *str != '\0'; str++)
{
ptr = match(str, (char *)substr);
if (ptr != NULL)
{
break;
}
}
while (*str++ = *ptr++)
{
;
}
return 1;
}
3、
void reverse_string(char *string)
{
char temp;
char * last;
last = string;
if (string != NULL)
{
while (*last != '\0')
{
last++;
}
last--;
while (string > last)
{
temp = *last;
*last = *string;
*string = temp;
string--;
last++;
}
}
}
分享到:
相关推荐
c和指针(pointers on c)习题答案(课后答案补充)
Pointers On C C和指针 英文版 答案
c与指针这本书的例子程序,原书是国外的大牛写的 我拿来分享一些
C语言课件:第十章 指针(Pointers).ppt
函数功能:在一个字符串中进行搜索,查找所有在一个给定字符集合中出现的字符
经典的书籍,添加了目录,参阅交流后请购书。
C语言四书之一。希望对C语言出血者有所帮助。
pointers on c 第二章课后编程练习源代码
Pointers On C brings the power of pointers to your C programs. Designed for professionals and advanced students, Pointers on C provides a comprehensive resource for those needing in-depth coverage of ...
Pointers on C, 针对指针的基本和高级特性的介绍
pointers on c第五章编程练习1,从标准输入读取字符,并将其中的大写字母转换为小写字母后,写到标准输出中
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Contents A ...
pointers on c第四章编程练习6,从一个字符串中提取一个子字符串
判断一个n*n的矩阵是否为单位矩阵。通过VC6.0编译
质数的ERATOSTHENES 筛选法。
POINTERS ON C 第九章编程练习11统计某个单词出现的个数,示例为单词the。VC6.0编译通过
C语言:第十章 指 针(Pointers).ppt