Thread: SAVE data from double linked list into .bin file and load it...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    struct data
    {
    	int idPaciente;
    	int idMedico;
    	int especialidade;
    	int horaConsulta;
    	int faixaEtaria;
    	int duracao;
    
    	int tipoConsulta;
    	char desc[100];
    
    	Data dataConsul;
    	Hora horaMarcacao;
    } test;
    fprintf(fp,"%d,%d,%d,%d,%d,%d,%d,%s\n",
    	   test.idPaciente,
    	   ...
    	   test.desc);
    for each node
    when you read it line by line and use sscanf to fill node data back...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  2. #2
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    ok...first step done :-D

    i've managed to save the data into the .txt file:
    Code:
    void guardarConsultas(pnoCons p)
    {
    	FILE *f;
    
    	f = fopen("consultas.txt", "w");
    
    	while(p != NULL)
    	{
    		fprintf(f, "%d\n%d\n%d\n%d\n%d\n%d\n%s%d\n%d %d %d\n%d %d %d\n",
    				p->idPaciente, p->faixaEtaria, p->tipoConsulta, p->horaConsulta, 
    				p->especialidade, p->duracao, p->desc, p->idMedico, 
    				p->horaMarcacao.hora, p->horaMarcacao.min, p->horaMarcacao.seg,
    				p->dataConsul.dia, p->dataConsul.mes, p->dataConsul.ano);
    
    		p = p->prox;
    	}
    
    	fclose(f);
    }
    consultas.txt
    123456
    1
    2
    2
    5
    40
    desc
    123456
    2 37 31
    17 4 2008
    but know the tricky part...load the data :-(

    how do i do that know?
    "Artificial Intelligence usually beats natural stupidity."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 07:53 PM
  2. Replies: 13
    Last Post: 04-26-2008, 08:29 PM
  3. Using a linked list globally and File I/O
    By Leftos in forum C Programming
    Replies: 46
    Last Post: 01-07-2008, 11:21 AM
  4. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 04:49 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM