home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / x / 14709 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.6 KB  |  58 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!primerd.prime.com!boddu!alvin
  3. From: alvin@boddu.prime.com (Alvin)
  4. Subject: Help! Why this small program core dump ?
  5. Message-ID: <1992Jul31.160542@boddu.Prime.COM>
  6. Sender: usenet@primerd.prime.com (Usenet)
  7. Organization: Prime Computer R&D
  8. Date: Fri, 31 Jul 1992 20:14:33 GMT
  9. Lines: 47
  10.  
  11. Hi,
  12.  
  13.     I am pretty new to XWindow. I have the following codes that core dumped.
  14. I cannot find what is wrong ! Before it calls XtInitialize, it just go into
  15. a loop which read a line from the file and put it into a char pointer array.
  16. It core dumps in XtInitialize. Here is the code. Any help is appreciated !
  17.  
  18. -Alvin
  19.  
  20. ------------------------------------------------------------------------
  21. #include <stdio.h>
  22. #include <Xm/Xm.h>
  23. #define MAXLINES 10
  24.  
  25.  
  26. char *account[MAXLINES];
  27. char temp[20];
  28.  
  29. main(argc, argv)
  30. int argc;
  31. char *argv[];
  32. {
  33.     XtAppContext app;
  34.     Widget toplevel;
  35.     int i;
  36.     int len;
  37.     int noentry;
  38.     FILE *account_file;
  39.     account_file = fopen("account", "r");
  40.     i = 0;
  41.     while(fgets(temp, 21, account_file) != NULL) {
  42.         len = strlen(temp);
  43.         account[i] = (char *)calloc(len,1);
  44.         strcpy(account[i], temp);
  45.         i++;
  46.     }
  47.     fclose(account_file);
  48.     noentry = i;
  49.  
  50.     toplevel = XtVaAppInitialize(&app, "Major", NULL, 0, &argc, argv,
  51.                                   NULL, NULL);
  52. }
  53.  
  54.    Feng-shun (Alvin) Chang             |    
  55.    Software Support Analyst            |   We need more "love" than "hate"  
  56.    Prime Computers, Inc.               |
  57.    Email : ALVIN@CSSS-A.PRIME.COM      |
  58.