-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.c
More file actions
63 lines (53 loc) · 1.28 KB
/
util.c
File metadata and controls
63 lines (53 loc) · 1.28 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "util.h"
/// cpf char para inteiro
void cpftoi(char str[],int *v, int tamArray){
int tam,cont,num;
char cnum;
tam = strlen(str);
cont = 0;
for(int i=0; i < tam; i++){
if(str[i] != '.' && str[i] != '-' && str[i] != '/'){
if(str[i]=='0'){
v[cont]= 0;
cont +=1;
}
else{
cnum = str[i];
num = atoi(&cnum);
v[cont] = num;
cont +=1;
}
}
}
// se ainda sobrar espacos, porque a pessoa digitou qtd insuficiente de numeros, ele preenche com -1
if((cont+1) != tamArray){
while((cont+1) <= tamArray){
v[cont] = -1;
cont++;
}
}
}
// Retirada do site https://wagnergaspar.com/como-converter-uma-string-em-maiusculo-ou-minusculo-em-qualquer-so-com-a-linguagem-c/
void transformUpper(char s1[], char s2[]){
int i = 0;
while(s1[i] != '\0'){
s2[i] = toupper(s1[i]);
i++;
}
s2[i] = '\0';
}
char* pegarDoisUltimos(char string[]){
int len;
char *caracteres;
caracteres = (char*) malloc(3*sizeof(char));
len = strlen(string);
caracteres[0] = string[len-2];
caracteres[1] = string[len-1];
caracteres[2] = '\0';
return caracteres;
}