Usando "sscanf" para Dividir String com Delimitadores em C
Publicado por Mauricio Ferrari em 26/02/2021
[ Hits: 4.786 ]
Blog: https://www.youtube.com/@LinuxDicasPro
#include <stdio.h> #include <stdlib.h> int main() { char *teste = (char *)malloc(sizeof(char)); teste = "10/20/30"; int a, b, c; sscanf(teste, "%d/%d/%d", &a, &b, &c); printf(" Resultado: %d %d %d ", a, b, c); teste = "pera,uva,figo"; char *str1 = (char *)malloc(sizeof(char)); char *str2 = (char *)malloc(sizeof(char)); char *str3 = (char *)malloc(sizeof(char)); sscanf(teste, "%[^,],%[^,],%[^,]", str1, str2, str3); printf(" Resultado: %s %s %s ", str1, str2, str3); return 0; }
Instalando o IPTVnator no Slackware
Incluindo o libmediainfo corretamente em um arquivo CMakeFiles.txt para uso em seus projetos
Resolvendo o "Could not open /dev/vmmon" do VMWare no Linux
Instalando o FrostWire no Deepin 20
Instalando o p7zip-desktop no Deepin 20
Corrigindo o bug "file format not recognized" após atualizar glib2
Compilando no Debian Wheezy 7.5
Verificar conversão de tipo em C/C++
Programando em C/C++ no Eclipse
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04