當前位置:首頁 » 編程語言 » 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;
}