跪求各位大虾:学校要求做课设,哪位能帮用c编一下,有重谢!

来源:百度知道 编辑:UC知道 时间:2024/05/28 02:57:02
编写函数完成如下功能:在指定的字符串中搜索给定的字符,若字符串中有此字符,则什么都不做,否则,将此字符插入到字符串的最后。
函数原型为:void fun (char *str,char ch);
能具体一点吗,本人刚开始学习c语言,谢谢 ,你给我的程序根本就运行不了

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <malloc.h>
#define MAXLEN 100
#define N 80
void fun(char *str,char ch)
{
while(*str&&*str!=ch)
str++;
if(*str=='\0')
{
str[strlen(str)-1]=ch;
str[strlen(str)+1]='\0';
}
main()
{
char s[81],*t;
void NONO();
printf("Enter a string:\n");
fun(char *str,char ch);
printf("The same string is:\n");
puts(s);
NONO();

}