11.07.2015 Views

Manual de "C"

Manual de "C"

Manual de "C"

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

- Um pointer para caracter não aloca área, portanto não po<strong>de</strong> ser usado em comandoscomo scanf ou strcpy, sem a <strong>de</strong>vida alocação da memória necesária.Erros <strong>de</strong> programadores Pascal :- Omissão do parênteses em funções sem parâmetros.- In<strong>de</strong>xação <strong>de</strong> arrays multidimensionais (a[i][j] e não a[i,j]).- Esquecimento que "C" consi<strong>de</strong>ra para nomes <strong>de</strong> variáveis tanto as maiúsculasquanto as minúsculas.- Colocar ";" em excesso ao final <strong>de</strong> blocos e <strong>de</strong>finição <strong>de</strong> funções.APÊNDICE D - EXEMPLO DE PROGRAMA :#inclu<strong>de</strong> struct nodo {};char texto [80];struct nodo *prox;struct nodo *novonodo;struct nodo *raiz;struct nodo *nodoptr;char textaux [70];int continua;main( ){continua = 1;raiz = (struct nodo *)malloc(sizeof(struct nodo));printf ("\n\n*** CRIACAO DE UMA LISTA ENCADEADA ***\n\n");strcpy (raiz->texto,">");raiz->prox = '\0';nodoptr = raiz;printf ("Entre com o Texto : ");gets (textaux);while (continua == 1){novonodo = (struct nodo *)malloc(sizeof(struct nodo));strcpy (novonodo->texto,textaux);novonodo->prox = '\0';nodoptr->prox = novonodo;nodoptr = novonodo;printf ("Entre com o texto : ");gets (textaux);if (strcmp(textaux,"FIM") == 0)continua = 0;}printf ("\n\n>>> FIM DA ENTRADA DE DADOS");printf ("\n\n\n*** LISTAGEM DA ESTRUTURA DE DADOS ***\n\n");nodoptr = raiz;printf ("%s\n",nodoptr->texto);while (nodoptr->prox != '\0')

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!