Re: Another newbie EXC_BAD_ACCESS in C
Re: Another newbie EXC_BAD_ACCESS in C
- Subject: Re: Another newbie EXC_BAD_ACCESS in C
- From: John Stiles <email@hidden>
- Date: Fri, 13 Jan 2006 18:47:30 -0800
Without reading the code, might I suggest running it with the
debugger enabled? Xcode has a useful "Build & Debug" button which
will pinpoint the line of failure.
On Jan 13, 2006, at 6:33 PM, W. Thomas Leroux wrote:
Hello all,
I'm trying my first foray into writing a (shell) program for OSX -
it has been a *every* long time since I have looked at C, but here
is what I have generated:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int iArgc, char *pArgv[])
{
char *da = "A";
char *db = "C";
char *dc = "G";
char *dd = "T";
char dna1 [100000] = {0};
int random;
int iterations = 120000;
int iterations1 = 2;
//int iterations1 = 100000;
int MAXVALUE = 3; // limit selection from 0 to 3.
strcpy(dna1,"");
int j = 1;
for (j = 0; j < iterations1; j++) {
//loop one
int i = 1;
for (i = 0; i < iterations; i++) {
// fill 100000 character buffer loop
random = rand() % (MAXVALUE +1);
if(random == 1)
strcat(dna1,da);
else if (random == 2)
strcat(dna1,db);
else if (random == 3)
strcat(dna1,dc);
else
strcat(dna1,dd);
// printf ("%c%c%c%c", dna1, dna2, dna3, dna4);
}
//write the buffer to the disk, then clear it
FILE *fp;
fp=fopen("//Users//wtl//Documents//dna3.txt", "a");
fprintf(fp, "%c", dna1);
fclose(fp);
clear(dna1);
}
printf ("ALL DONE!");
return 0;
}
However, when I Build and Debug it, I get an EXC_BAD_ACCESS error -
put no specific line error. I'm a bit befuddled, because it looks
like the code should work, and I figured someone with a fresh eye
would spot the issue faster than I can.
Thanks!
Thomas.
--
All about me! Me! Me! Me!
http://www.wtl.technomages.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden