473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem with linked list program

I'm trying to write C program that reads data from dbf fajl. This is my first program with linked list. When I delete line1 and line2 program works, but then I dont have linked list. And when I use line1 and line2 data dont read correct. How can I read a data from dbf and store it in struct and all that with linked list.


Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <alloc.h>
  3. #include <stdlib.h>
  4. typedef struct cvor
  5. {
  6. char indikator;
  7. char radnik[6];
  8. char stavka[2];
  9. char oour[2];
  10. char grupa[5];
  11. char rad[2];
  12. char algodb[1];
  13. char algdop[1];
  14. char stad[1];
  15. char prebiva[2];
  16. char tekmes[2];
  17. char tekobr[2];
  18. char bod[10];
  19. char sati[3];
  20. char koefa[7];
  21. char vrboda[13];
  22. char pojkoef[7];
  23. char ucinak[7];
  24. char n6[10];
  25. char neto[14];
  26. char bruto[15];
  27. char obr[1];
  28. char ggmm[4];
  29. char prepravi[12];
  30. char pravi_neto[12];
  31. char sifra[6];
  32. struct cvor *sledeci;                                                LINE 1
  33. }PODACI;
  34.  
  35. PODACI *pocetak,*novi;
  36.  
  37. int main(void)
  38. {
  39. FILE *fptr;
  40. int i=0,j;
  41. pocetak=NULL;
  42. fptr=fopen("ldprizar.dbf","r");
  43. fseek(fptr,832,SEEK_SET);
  44. while(i<19)
  45. {
  46. novi=malloc(sizeof(PODACI));
  47. fread(novi,sizeof(PODACI),1,fptr);
  48. novi->sledeci=pocetak;                                              LINE 2
  49. pocetak=novi;
  50. fwrite(novi->radnik,sizeof(char)*6,1,stdout);
  51. fwrite(novi->neto,sizeof(char)*14,1,stdout);
  52. putchar('\n');
  53. i++;
  54. }
  55. printf("\n\n");
  56. getchar();
  57. fclose(fptr);
  58. return (0);
  59. }
Feb 29 '08 #1
0 1167

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Kay | last post by:
This function is used getline function to get data. The data is stored as String. I want to add it in a linked list. However, the strcpy that I have pointed cause the program segementation fault....
10
by: Ben | last post by:
Hi, I am a newbie with C and am trying to get a simple linked list working for my program. The structure of each linked list stores the char *data and *next referencing to the next link. The...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
7
by: Fernando Barsoba | last post by:
Hi, After following the advice received in this list, I have isolated the memory leak problem I am having. I am also using MEMWATCH and I think it is working properly. The program does some...
11
by: bofh1234 | last post by:
Hello, I am having a problem with linked lists. My program is based on a client server model. The client sends some packets of data to the server. The server reads those packets and is...
4
by: Niks | last post by:
Hey.. I tried to creat a linked list by using a structure defined in a class as follows: class LL { struct node { int data; node *next,*previous
1
by: theeverdead | last post by:
Ok I have a file in it is a record of a persons first and last name. Format is like: Trevor Johnson Kevin Smith Allan Harris I need to read that file into program and then turn it into a linked...
7
by: davidson1 | last post by:
Hello friends, I want ur help regarding singly linked list in C,I tried in net,But it is confusing and difficult.I want singly linked list in a simple way of Understanding.Please Help Me I want...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.