antiblock
diamwall
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
SINVAL o.O

Problema Armazenar Int

4 posts in this topic

Bem estou tentando armazenar um CPF em uma variável do tipo int, tentei por float, double mais sempre sai valor diferente

 

Código normal:

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


int main() {
int CPF;
printf("Digite CPF:");
scanf("%d", &CPF);
printf("CPF: %d", CPF);
system("pause");
return 0;
}

http://prntscr.com/7d03qa

Tentei fazer alocação dinâmica da memoria e mesmo assim n dá

 

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


int main() {
int *CPF;
CPF = (int *) calloc(50, sizeof(int));
printf("Digite CPF:");
scanf("%d", CPF);
//gets(CPF);
printf("CPF: %d", *CPF);
free(CPF);
system("pause");
return 0;
}

http://prntscr.com/7d04r9

 

se alguém souber o que posso fazer para armazenar número, por favor me diga;

 

(já tentei por long long mais pelo visto não resultou)

 

Share this post


Link to post
Share on other sites
antiblock
https://i.imgur.com/aJ17bf7.gif

Pelo pouco relacionado com C que aprendi no curso, penso que tens que criar uma tabela e escrever lá os dados.

Share this post


Link to post
Share on other sites

Sim, assim é por array mais teria que fazer for pra preencher e digitar um número de cada vez, mais aí é melhor usar char.

Share this post


Link to post
Share on other sites

Not really,  metes a variável dentro de um explode e fazes o teu array com base no número inteiro e depois fazes um implode e juntas tudo...

 

Mas mesmo assim acho estranho não dar com float

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this