-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
71 lines (62 loc) · 1.5 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <locale.h>
void removeCaracteresEspeciais(char str[50]){
int s = 0;
int d = 0;
while (str[s] != '\0') {
if (isalpha(str[s])) {
str[d] = str[s];
++d;
}
++s;
}
str[d] = '\0';
}
void naoRemoveOEspaco(char *valor, char str2[50],const char *remover, const char *substituir) {
int i = 0, cnt = 0;
int len1 = strlen(substituir);
int len2 = strlen(remover);
char novovalor[50] = {};
i = 0;
while (*valor) {
if (strstr(valor, remover) == valor) {
strcpy(&novovalor[i], substituir);
i += len1;
valor += len2;
}
else
novovalor[i++] = *valor++;
}
strcpy(str2,novovalor);
removeCaracteresEspeciais(str2);
}
void removeExtras(char *valor2, char str3[50],const char *remover2, const char *substituir2) {
int i = 0, cnt = 0;
int len1 = strlen(substituir2);
int len2 = strlen(remover2);
char novovalor2[50] = {};
i = 0;
while (*valor2) {
if (strstr(valor2, remover2) == valor2) {
strcpy(&novovalor2[i], substituir2);
i += len1;
valor2 += len2;
}
else
novovalor2[i++] = *valor2++;
}
strcpy(str3,novovalor2);
}
int main()
{
char nome1[50];
char nome2[50];
char nome3[50];
setlocale(LC_ALL, "Portuguese");
naoRemoveOEspaco(nome1,nome2," ","xqz");
removeExtras(nome2,nome3,"xqz"," ");
}