-
Notifications
You must be signed in to change notification settings - Fork 0
/
29.cpp
43 lines (42 loc) · 749 Bytes
/
29.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// Main.c
// Homework
//
// Created by Daniel Eilot on 2016/1/2.
// Copyright © 2015 GeniusV. All rights reserved.
//
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void dele (char str[], char ch);
int main ()
{
char str[100];
char ch;
gets (str);
printf ("Del >");
ch = getchar ();
dele (str, ch);
puts (str);
return 0;
}
void dele (char str[], char ch)
{
int i, ct;
for (i = 0; str[i] != '\0'; i ++)
{
if (str[i] == ch)
{
ct = i;
while (1)
{
str[ct] = str[ct + 1];
if (str[ct] == '\0')
{
break;
}
ct ++;
}
}
}
}