Sample input:
100 Doe John 15000
101 Liu Peter 12500
102 Kim Anna 12800
103 Ali Abbas 14800
sample output:
100 John Doe 15000.00
101 Peter Liu 12500.00
102 Anna Kim 12800.00
103 Abbas Ali 14800.00
I'm pretty sure my algorithm is correct. Again, according to some of my debug tests, the Abort occurs after reading the first line.
18 Replies - 1227 Views - Last Post: 24 October 2011 - 04:40 PM
#16
Re: searching for a file, writing to a different file and Unix.
Posted 24 October 2011 - 04:12 PM
#17
Re: searching for a file, writing to a different file and Unix.
Posted 24 October 2011 - 04:25 PM
When I ran this program through my debugger the problem was detected on line 61:
At this point you have never initialized j.
Jim
while(strptr !=NULL)
{
strcpy(tokens[j], strptr); // 61
At this point you have never initialized j.
Jim
#18
Re: searching for a file, writing to a different file and Unix.
Posted 24 October 2011 - 04:31 PM
That's part of the string tokenization. It's odd since singling out the code it doesn't throw any errors. j is initialized in it's original declaration to 0. Just in case, I set it to 0 just before the string tokenization. After running I got a trap at the same point.
I don't think this is part of the problem.
I'm pretty sure it's ok, but is there something wrong with my gets() statement? admittedly my C is a bit rusty and maybe I'm taking something for granted since I've been doing more java lately, but in comparing these to examples on google there's no problems....
I don't think this is part of the problem.
I'm pretty sure it's ok, but is there something wrong with my gets() statement? admittedly my C is a bit rusty and maybe I'm taking something for granted since I've been doing more java lately, but in comparing these to examples on google there's no problems....
#19
Re: searching for a file, writing to a different file and Unix.
Posted 24 October 2011 - 04:40 PM
I don't see where you have initialized this variable anywhere. The following code doe not initialize anything except m.
After I initialize this variable the program runs to conclusion.
Show your code where you initialize this variable.
Jim
int i, j, k, l, m =0;
After I initialize this variable the program runs to conclusion.
Show your code where you initialize this variable.
Jim

New Topic/Question
Reply




MultiQuote


|