-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestao_14.c
55 lines (43 loc) · 1022 Bytes
/
questao_14.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
#include <stdio.h>
#include <stdlib.h>
void rmv_cadeia(char string[], int indice, int quant);
int main(){
int indice, quant;
char string[100];
printf("String -> ");
scanf("%[^\n]s", &string);
setbuf(stdin, NULL);
printf("Indice -> ");
scanf("%i", &indice);
setbuf(stdin, NULL);
printf("Quantidade removida -> ");
scanf("%i", &quant);
setbuf(stdin, NULL);
rmv_cadeia(string, indice, quant);
return 0;
}
void rmv_cadeia(char string[], int indice, int quant){
int i = 0;
char sub_string[100];
//printf("\nResulta em -> ");
//Passo o solicitado para minha auxiliar
while (i < quant){
//printf("%c", string[indice-1]);
sub_string[i] = string[indice-1];
i++;
indice++;
}
// Zero todos os elementos de string
i = 0;
while (string[i] != '\0'){
string[i] = NULL;
i++;
}
//Printa o vetor princial já modificado
i = 0;
while (i < quant){
string[i] = sub_string[i];
i++;
}
printf("\nResulta em -> %s", string);
}