您的位置:首页 > 其它

练习5-3&&5-4&&5-5

2014-01-25 19:31 176 查看
练习5-3
#include <stdio.h>
#include "chapter_5.h"

void Strcat(char *s, char *t) {//5-3
while (*s != '\0' && *t !='\0') {
++s;
}
while (*t != '\0') {
*(s++) = *t;
++t;
}
}


练习5-4

#include <stdio.h>
#include "chapter_5.h"

int Strend(char *s, char r) {//5-4
while (*s != '\0') ++s;

if (*(--s) == r)
return 1;
else
return 0;
}


练习5-5

#include <stdio.h>
#include <stdbool.h>
#include "chapter_5.h"

void Strncpy(char *s, char *t, int n) {//5-5
int count = 0;
while (*t != '\0' && count < n) {
*s = *t;
++s;
++t;
count++;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: