SINVAL o.O 728 Posted June 4, 2015 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
BabyWolf 87 Posted June 4, 2015 Pelo pouco relacionado com C que aprendi no curso, penso que tens que criar uma tabela e escrever lá os dados. 1 SINVAL o.O reacted to this Share this post Link to post Share on other sites
SINVAL o.O 728 Posted June 4, 2015 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
xXBoyDarkXx 328 Posted June 4, 2015 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 1 SINVAL o.O reacted to this Share this post Link to post Share on other sites