Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inclusão das variações do printf e scanf #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DirceuSilvestre
Copy link
Contributor

explicações sobre o funcionamento do fprintf, sprintf, fscanf e sscanf

Copy link
Contributor

@yaansz yaansz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seria legal um exemplo mais complexo do uso algo como

#include <stdio.h>
#include <stdlib.h>

int main(void){
	int dia, mes, ano;
    
    char *source = (char *) malloc(100 * sizeof(char));
    char *target = (char *) malloc(100 * sizeof(char));
    source = "27/05/2001";
    

    sscanf(source, "%d/%d/%d", &dia, &mes, &ano);
    printf("source: %s\n", source);
    
    sprintf(target, "-> %d-%d-%d", dia, mes, ano);
    printf("target: %s\n", target);
}

n adicionei comentários, é só uma possibilidade 🤯


sscanf(variavel2, "%d", &variavel1) // Passa o conteúdo da variável2 convertido para inteiro para a váriavel1

// Caso o sscanf não tivesse sido usado, teriamos que programar o código para passar por cada casa do vetor variavel2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acho que esse comentário pode confundir iniciantes, o uso das funções atoi, atof e etc conseguem converter

Correções e melhorias após revisão, visando melhor entendimento do leitor, sobre as variações do printf e scanf
@yaansz
Copy link
Contributor

yaansz commented Oct 14, 2021

acho que o problema do atoi, atof ainda está na versão final

@jpaulohe4rt
Copy link
Owner

Algum update dessa PR? @DirceuSilvestre @yaansz

@yaansz
Copy link
Contributor

yaansz commented Jan 3, 2022

da minha parte não

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants