Boa noite, senhores. Gostaria da ajuda de alguém aqui do fórum, pois, o meu compilador( Dev C++). Aponta diversos erros e warnings no meu código.
Abaixo do código fonte segue a lista de erros
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#define TAM 121
int main (void) {
int a, b, j, i, octal;
char nb[TAM];
bool valido;
printf("Digite um numero binario:\n");
scanf("%120[^\n]", nb);
j = 0;
while (nb[j] == ' '); {
j++;
}
for (i = 0; j <= strlen(nb); j++; i++) {
nb[i] = nb[j];
}
j = strlen(nb) - 1;
while (nb[j] == ' '); {
j--;
}
valido = true;
for ( i = 0; i < strlen(nb); i++) {
if ((nb[i] != '0') && (nb[i] != '1')) {
printf("Numero binario invalido\n");
valido = false;
break;
}
}
a = strlen(nb) / 3;
b = strlen(nb) % 3;
for (i=0; i<a; i++) {
j = i * 3 + b;
octal = (nb[j] - 48) * 4 + (nb[j + 1] - 48) * 2 + (nb[j + 2] - 48);
printf("%c%c%c ~> %d\n", nb[j], nb[j + 1], nb[j + 2], octal);
}
printf("\n");
}
printf("\n");
system("PAUSE");
return (0);
}
Erros:
27 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before ';' token
27 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before ')' token
At top level:
30 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before '=' token
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c `nb' undeclared here (not in a function)
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
32 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "while"
35 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
36 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "for"
39 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c redefinition of 'valido'
35 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c previous definition of 'valido' was here
39 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
40 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "break"
44 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
44 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
45 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
45 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
48 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "for"
50 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c conflicting types for 'printf'
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c a parameter list with an ellipsis can't match an empty parameter name list declaration
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c conflicting types for 'printf'
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c a parameter list with an ellipsis can't match an empty parameter name list declaration
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
54 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
54 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
56 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
56 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
61 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
61 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
Pergunta
rodiisilva
Boa noite, senhores. Gostaria da ajuda de alguém aqui do fórum, pois, o meu compilador( Dev C++). Aponta diversos erros e warnings no meu código.
Abaixo do código fonte segue a lista de erros
Erros:
27 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before ';' token
27 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before ')' token
At top level:
30 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before '=' token
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c `nb' undeclared here (not in a function)
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
31 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
32 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "while"
35 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
36 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "for"
39 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c redefinition of 'valido'
35 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c previous definition of 'valido' was here
39 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
40 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "break"
44 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
44 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
45 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c initializer element is not constant
45 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
48 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before "for"
50 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c conflicting types for 'printf'
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c a parameter list with an ellipsis can't match an empty parameter name list declaration
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c conflicting types for 'printf'
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c a parameter list with an ellipsis can't match an empty parameter name list declaration
51 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
54 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
54 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
56 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
56 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
61 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c syntax error before string constant
61 E:\Documents and Settings\Administrador\Desktop\Trabalhos de CB\M100127398.c [Warning] data definition has no type or storage class
Agradeço a ajuda/atenção.
W. Rodrigo
Graduando - CiC ( Licenciatura )
Universidade de Brasília
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.