[ create a new paste ] login | about

Link: http://codepad.org/e4ICYljh    [ raw code | output | fork ]

C, pasted on Oct 13:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct PESSOA{
	int b;
	struct PESSOA *nseg;
}pessoa;



void novonodo(pessoa *el,int c){
	el=(pessoa *)malloc(sizeof(malloc));
	el->b=c;
		
}
pessoa *insertlast(pessoa *el,pessoa *l){
	pessoa *aux=l;
	if(l==NULL)return(el);
	while(aux->nseg!=NULL)
	aux=aux->nseg;
	aux->nseg=el;
	return l;
	
} 
void show(pessoa*l){
	
	while(l!=NULL){
		printf("%d",l->b);
		l=l->nseg;
	}
}


int main(){
	pessoa *l=NULL;
	pessoa *el;
	int a;
	FILE *fp;
	fp=fopen("boas.txt","rt");
	if(fp==NULL){
		printf("erro");
		exit(1);
	}
	
	l=(pessoa *)malloc(sizeof(pessoa));
	
	
	while(fscanf(fp,"%d",&a)!=EOF){
		novonodo(el,a);
		l=insertlast(el,l);
		show(l);
		
		
	}
	
	
	return(0);
}


Output:
1
erro


Create a new paste based on this one


Comments: