当前位置:首页 » 编程语言 » del函数原型如何编译c语言
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

del函数原型如何编译c语言

发布时间: 2022-06-24 22:24:14

c语言编程问题

voiddel(char*s,intn,intlen)
{char*p,*q;
for(p=s;*p;p++);
if(n<0||n+len>p-s){printf("error");return0;}
p=s+n;
q=p+len;
for(;*p=*q;);
}

㈡ c语言编程作业 函数strdel,求指导!!

请问接口是什么
函数的原型是什么

#include <stdio.h>

void strdel(char*s,char del)
{
int i,j;
for(i=0,j=0;s[i];i++)
{
if(s[i]!=del)
s[j++] = s[i];
}
s[j] = 0;
}

int main()
{
char s[1000];
char del;
while(gets(s)!=NULL)
{
scanf("%c",&del);
strdel(s,del);
printf("%s\n",s);
}
}

㈢ 【C语言编程】写一个函数del,删除动态链表中指定的结点

#include <stdio.h>
#include <malloc.h>
#include <conio.h>
typedef struct node //定义节点
{
int value;
struct node* next;
}note;
note* head = NULL;

void del (note** head, int k)//删除链表
{
note* pp;
note* pt;
note* pq;
pp = *head;
if ((*head)->value == k)//如果头结点的值等于k,删除头结点
{
*head = (*head)->next;
return;
}
while(pp->value != k)
{
pt = pp;
pq = pp->next;
pp = pq;
}
pt->next = pp->next;//删除结点

}
void insert(note** head, int q)//建立链表
{
note* pp;
note* pt;
note* p = (note*)malloc(sizeof(note));
p->value = q;
p->next = NULL;
pp = *head;
if (*head==NULL)
{
*head=p;
return;
}
while(pp->next!=NULL)
{
pt = pp->next;
pp = pt;
}
pp->next = p;

}
void print(note* head)//打印链表
{
note* pp;
while(head!=NULL)
{
printf("%d ", head->value);
pp = head->next;
head = pp;
}
}
int main()
{
int i;
int n,k,value;
scanf("%d %d",&n, &k);
for(i=0; i<n; i++)
{
scanf("%d", &value);
insert(&head, value); //把head的地址传过去
}
del(&head, k);
print(head);
getch();//随意按个键退出界面
return 0;
}

㈣ C语言问题 实现在字符串的内部删除字符串的函数del。

#include<stdio.h>
voiddel(char*s,intn,intlen)
{char*p;
s+=n;
for(p=s+len;*s++=*p++;);
}
intmain()
{chars[]="apple";
if(s==NULL||n<0)
{printf("error");
return0;
}
del(s,2,2);
puts(s);
return0;
}

㈤ C语言编程 编写一个函数delchar(char s[],char ch) 将数组s存放的字符串中

voiddelchar(chars[],charch)
{
char*pre=s;
char*aft=s;

while(*aft)
{
if(*aft!=ch){
*pre=*aft;
++pre;
++aft;
}else{
++aft;
}
}
*pre='';
puts(s);
}

㈥ c语言编写函数,将一个字符串str中指定的字符ch删去,函数原型是void delchar(char*str,char ch)

1、打开visual C++ 6.0-文件-新建-文件-C++ Source File。

㈦ 用c编一个程序,删除字符串的一部分,函数原型如下: int del_substr(char*str ,char const *substr)

#include<stdio.h>
int del_substr(char *str,char const *substr)
{
int flag=0,n;
char *p=str,*q=(char*)substr,*pp,*qq;
while(*p){
if(*p==*q){
pp=p;qq=q;n=0;
while(*pp&&*qq){
if(*pp!=*qq){break;}
else{
pp++;qq++;n++;
}
}
if(!(*qq)){
pp=p+n;
while(*pp){
*(pp-n)=*pp;
pp++;
}
}
*(pp-n)='\0';
}
p++;
}

return 0;
}
void main()
{
char s[15]="abcdebcfg",t[3]="bc";
del_substr(s,t);
puts(s);

}

㈧ 关于设计del函数的C程式

修改后的程序符合ANSI C标准,修改的地方较多,请自行对比二者的不同之处

#include "stdio.h"
#include "string.h"
int del(char *s,int i,int n)//s=str,i=start,n=number
{

if(i>=0&&n>0&&i+n<=(int)strlen(s))
{
s[i-1]='\0';
strcat(s,s+i-1+n);
return(1);
}
else
return(0);
}
int main(void)
{
char s[80];
int j,n;
printf("\nPlease input a character:");
scanf("%s",s);
printf("\n开始删除的位置:");
scanf("%d",&j);
printf("\n删除字符数:");
scanf("%d",&n);
if (del(s,j,n)) {
printf("\n删除完毕:");
printf("%s\n",s);
}
else printf("删除失败!\n");
return 0;
}