66问答网
所有问题
当前搜索:
c语言删去字符串特定字符
删除字符串
中某个
指定字符
,用
C语言
答:
如图
...
删除字符串
中所有非字母字符,然后将删除后的结果输出。
答:
include <stdio.h> int main(){ char a[80];gets(a);int i, j = 0;for(i=0; a[i]; i++)if((a[i] >= 'a' && a[i] <='z') || (a[i] >='A' && a[i] <= 'Z')){ a[j] = a[i];j++;} a[j] = '\0';puts(a);return 0;} ...
C语言中
如何把
字符串
中
某
一位清空?
答:
假设这个一维
字符串
数组是str[80]---不一定是一维字符串数组,多维数组,结构都可以。方法1:使用运行库函数memset():memset(str, 0, sizeof(str));方法2:使用Windows API函数ZeroMemory():ZeroMemory(str, sizeof(str));但不能用于指针。指针的情况下,必须这样:struct mystr *p;...memset(...
C语言
问题:从一个
字符串
里
删掉字符
b
答:
define N 100 include "stdio.h"void main(){ int i;char a[N];printf("输入一个
字符串
:\n");gets(a);for (i=0;a[i]!='\0';i++)if (a[i]!='b')printf("%
c
",a[i]);printf("\n");}
c语言
想要实现
删除
一个
字符串
里的一个字符,问题出在哪
答:
要输入
字符串
,数组用char delete是关键字,不能使用 include<stdio.h>#include <string.h>#include <math.h>int main(){void delch(char
c
, char str[], int n);char a[5];scanf("%s", a);printf("%s\n", a);delch('b', a, 5);return 0;}void delch(char c, char str[]...
C语言
问题:对任意一个
字符串
,将
指定
位置的
字符删除
。我的程序有点问题...
答:
char 数组其实在最后一个位置都是有个 '\0' ,你这么做
字符串
的终止位置没变,也就是说字符串长度还是一样的~
...再输入一个字符,编写函数delechar(),将
字符串
中该
字符删除
...
答:
include<string.h> define MAX 80 void delechar(char str[],char a){ int i=0,j;while(str[i]!='\0'){ if(str[i]==a){ for(j=i;str[j]!=0;j++){ str[j]=str[j+1];} } i++;} } int main(void){ int i;char a,str[MAX];gets(str);scanf("%c",&a);dele...
c语言删除字符串
中
的指定字符
后的所有字符
答:
char * fun(char * s){ char *s1 = s; //s1指向
字符串
首地址 while((*s!='?')&& (*s!=0) ) //字符不为结束符或者不为?,指向下一个字符 s++; *s=0; //将这个字符置为结束符 return s1;}main函数直接调用这个函数就可以了。
★
c语言
★如何
删除字符串
中的第一位?★
答:
直接用strcpy函数。include "stdio.h"include <string.h> void main(){ char str1[10]="^abc";strcpy(str1,str1+1);printf("
删除
后的
字符串
为:\n");puts(str1);}
C语言
:任意输入一个
字符串
s,将s中所有的
字符c删除
答:
include <stdio.h> void main(){ char s[100];char *p,*q;printf("Please input a string:\n");scanf("%s", s);p=s;while(*p && *p!='
c
') p++;q=p;while(*q){ if(*q!='c') *p++=*q;q++;} p='\0';printf("The result is:\n");printf("%s", s);} ...
棣栭〉
<涓婁竴椤
6
7
8
9
11
12
13
14
10
15
涓嬩竴椤
灏鹃〉
其他人还搜