home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16256 < prev    next >
Encoding:
Text File  |  1992-11-09  |  1.6 KB  |  61 lines

  1. Path: sparky!uunet!usc!sdd.hp.com!spool.mu.edu!uwm.edu!rpi!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u17868
  2. Organization: University of Illinois at Chicago
  3. Date: Mon, 9 Nov 1992 23:57:22 CST
  4. From: <U17868@uicvm.uic.edu>
  5. Message-ID: <92314.235722U17868@uicvm.uic.edu>
  6. Newsgroups: comp.lang.c
  7. Subject: largest structure size on pc (in c)
  8. Lines: 51
  9.  
  10. my  program is listed below. it is very short. All I am trying to do is to
  11. read from a file. But, I think the problem is that the structure size is too bi
  12. g. It compiles successfully.I am using Turbo C 2.0. When I run it I get the mes
  13. sage "Null Pointer Assignment". I tried different ways that is using malloc, wi
  14. thout malloc, defining structure as a tag and then declaring an instance, but n
  15. othing helpded. I have 2M RAM on my pc.Anyone has any suggestion send it to
  16. u17868@uicvm..cc.uic.edu
  17.  
  18. Thanks,
  19. Sikander
  20. ===================my program ============================================
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. struct {
  24.     int  id;
  25.     char  date[9];
  26.     char day[10];
  27.     int  stime;
  28.     int  length;
  29.     char location[10];
  30.     char with_who[10];
  31.     char phone[11];
  32.     char subj[10];
  33.     char note[10];
  34.         int  flag;
  35. }temp;
  36.  
  37. main()
  38. {
  39. int i;
  40. FILE *file_pointer;
  41.  file_pointer = fopen("activity.dat","rb+");
  42.  fseek(file_pointer,0,0);
  43.  
  44.  for(i=0;i<=4;i++)
  45.      {
  46.        scanf("%d",&temp.id);
  47.        gets(temp.date);
  48.        gets(temp.day);
  49.        scanf("%d",&temp.stime);
  50.        scanf("%d",&temp.length);
  51.        gets(temp.location);
  52.        gets(temp.with_who);
  53.        gets(temp.phone);
  54.        gets(temp.subj);
  55.        gets(temp.note);
  56.        scanf("%d",&temp.flag);
  57.        fwrite(&temp,sizeof(temp),1,file_pointer);
  58.        }
  59.  }
  60.  
  61.