Jump to content
Fórum Script Brasil
  • 0

Erro Código


Guest --Rogerio --
 Share

Question

Guest --Rogerio --

alguém pode me ajudar, a conversao de char para int esta dando errado, e mostra só 000.000.000-00.

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<conio.h>

int numero[11], i;

char cpf[11];

void main()

{

clrscr();

printf ("\n //*==========================================*");

printf ("\n //| Leitura dos numeros do CPF |");

printf ("\n //*==========================================*");

printf ("\n ");

printf ("\n Informe os 11 digitos do CPF: ");

for(i=1;i<= 11;i++)

{

if(i-1==3) printf(".");

if(i-1==6) printf(".");

if(i-1==9) printf("-");

cpf = getche();

numero = atoi (cpf);

cpf=' ';

}

printf("Numero completo do CPF\n");

for(i=1;i<=11;i++)

{

printf("%d",atoi numero);//numeros do CPF

if(i-1==2) printf(".");

if(i-1==5) printf(".");

if(i-1==9) printf("-");

}

while(!kbhit());

}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Guest --João --

Estive com problemas também, estou usando essa mesma base que você (peguei de um gerador de CNPJ).

O erro está aqui:

for(i=0;i<11;i++)

{

if(i-1==2) printf(".");

if(i-1==5) printf(".");

if(i-1==8) printf("-");

cpf = getche();

numero = atoi (cpf);

cpf=' ';

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.2k
    • Total Posts
      647.5k
×
×
  • Create New...