home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!pagesat!netsys!agate!stanford.edu!rock!concert!duke!news.duke.edu!acpub.duke.edu!gk1
- From: gk1@acpub.duke.edu (Gavin Kistner)
- Newsgroups: comp.sys.mac.programmer
- Subject: Beginner Think C question
- Summary: Crashes normally, not in debug
- Message-ID: <8990@news.duke.edu>
- Date: 23 Jan 93 00:14:15 GMT
- Sender: news@news.duke.edu
- Followup-To: gk1@acpub.duke.edu
- Organization: Duke University; Durham, N.C.
- Lines: 74
- Nntp-Posting-Host: raphael.acpub.duke.edu
-
- I'm trying to write my very first program on a Mac (except hello world)
- using Think C 5.0.2 & Think Reference.
- I'm fuddling along, and things are working alright if I'm stepping through
- in the debugger, but if I try to run the program without it, it crashes
- immediately. Not even CMD-OPT-ESC saves. I'd think I'm trashing system
- mem, but it does work fine with the debugger.
-
- Code follows. Please understand that this is my very first program
- attempting to use any procedures not my own. The code is messy. Bear with
- me.
-
- #include <Resources.h>
- #include <Types.h>
- #include <StandardFile.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- short GetFiles(void);
-
- #define NIL 0
- short fileRefs_g[255];
-
- /*********************************************/
-
- int
- main()
- {
- short error;
-
- error = GetFiles();
-
- return 0;
- } /*main*/
-
- /*********************************************/
-
- short
- GetFiles()
- {
- short loopCounter=0;
- SFReply openReply;
- Point boxPoint;
- SFTypeList fileKind;
-
- boxPoint.v = 20;
- boxPoint.h = 20;
- fileKind[0]='sfil';
- openReply.good = 1;
-
- while (openReply.good && (loopCounter < 256))
- {
- SFGetFile(boxPoint,NIL,NIL,1,fileKind,NIL,&openReply);
- if (openReply.good)
- fileRefs_g[loopCounter++] =
- OpenResFile(openReply.fName);
- if (openReply.good && (fileRefs_g[loopCounter-1] == -1))
- {
- printf("An error occured opening the selected
- resource file.\n");
- printf("Sorry.\nExiting program...\n");
- exit(1);
- } /*if*/
- } /*while*/
-
- if (loopCounter < 3) return 1;
- else return 0;
- } /*GetFile*/
-
- Anyone feeling like taking the time to look over this, and flame me if they
- find out what's wrong, please do so.
-
- Thanks,
-
- Gavin
-