
Enviado em 25/11/2018 - 10:14h
Olá, recetemente andei fazendo uns testes com strings em C e acabei me deparando com um problema esquisito. O problema....estou com preguiça de descrever (- É SERIO ISSO?), então só vou deixar o código abaixo para vocês examinarem e darem o veredito.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void get_string(char *__string, size_t max){
fgets(__string, max, stdin);
size_t len=strlen(__string);
if(__string[len-1]=='\n'){
__string[len-1]='\0'; //Tira a quebra de linha (o '\n').
}
}
int main(void){
char secret_word[56];
printf("\n[?] secret_word >");
get_string(secret_word, 56);
size_t wordlen=strlen(secret_word);
char secret[wordlen+1];
printf("\n\n[I] secret_word.........: %s\n", secret_word);
printf("[I] secret_word lenght..: %ld\n\n", wordlen);
for(size_t i=0; i<wordlen; i++){
if(secret_word[i]!=' '){
secret[i]='-';
}else{
secret[i]=' ';
}
}
secret[wordlen+1]='\0';
printf("[I] secret..........: %s\n", secret);
printf("[I] secret lenght...: %ld\n\n", strlen(secret));
return 0;
}
zherkezhi@zherkezhi-Lenovo-B40-30:~/Documents$ ./app
[?] secret_word >abacaxi
[I] secret_word.........: abacaxi
[I] secret_word lenght..: 7
[I] secret..........: -------
[I] secret lenght...: 7
zherkezhi@zherkezhi-Lenovo-B40-30:~/Documents$ ./app
[?] secret_word >macaco
[I] secret_word.........: macaco
[I] secret_word lenght..: 6
[I] secret..........: ------
[I] secret lenght...: 6
zherkezhi@zherkezhi-Lenovo-B40-30:~/Documents$ ./app
[?] secret_word >azeitona
[I] secret_word.........: azeitona
[I] secret_word lenght..: 8
[I] secret..........: --------4
[I] secret lenght...: 9
zherkezhi@zherkezhi-Lenovo-B40-30:~/Documents$ ./app
[?] secret_word >ilha da macacada
[I] secret_word.........: ilha da macacada
[I] secret_word lenght..: 16
[I] secret..........: ---- -- --------�
[I] secret lenght...: 17
IA Turbina o Desktop Linux enquanto distros renovam forças
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Atualizando o Fedora 42 para 43
Como saber se o seu e-mail já teve a senha vazada?
Como descobrir se a sua senha já foi vazada na internet?
copiar library para diretorio /usr/share/..... su com Falha na a... (1)
Problema em SSD ao dar boot LinuxMint LMDE FAYE 64 (3)
Instalação dualboot Windows 11 e Debian 13 (29)









