-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkadai2-2-1.c
53 lines (44 loc) · 885 Bytes
/
kadai2-2-1.c
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
44
45
46
47
48
49
50
51
52
53
#include <stdio.h> /* kadai2-2-1.c */
void capital_character(char *s, char c);
void remove_character(char *s);
int main(void)
{
char s[100], c;
printf("Input original string: ");
fgets(s,sizeof(s),stdin);
printf("Input lower character (to be capitalized): ");
c = getchar();
capital_character(s, c);
printf("After capitalization: %s\n", s);
remove_character(s);
printf("After removing capital characters: %s\n", s);
return 0;
}
void capital_character(char *s, char c)
{
char *p;
p = s;
while( *p != '\0'){
if((*p==c)){
*p = *p - ('a'-'A');
}
p++;
}
}
void remove_character(char *s)
{
char *p;
p = s;
while( *s != '\0'){
p=s;
if((*p >= 'A') && (*p <='Z')){
while(*p != '\0'){
*p = *(p + 1);
p++;
}
}
else {
s++;
}
}
}