Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Problem solved....I should kept the question but cause it's for a school project I didn't.
Posted
Updated 15-Nov-14 6:14am
v3
Comments
OriginalGriff 15-Nov-14 12:16pm    
Why delete your comments? :laugh:
Nelek 15-Nov-14 16:05pm    
Not only the comments, the question as well. Should we rollback? ;P :evilgrinse:
OriginalGriff 15-Nov-14 16:15pm    
I will admit I am very tempted.
It is rather rude to delete questions that could help others.

1 solution

I got a couple of (minor) errors - but I may have my C compiler set more strictly than you: it expects "classic" C, where declarations must precede any code in the function - so I had to move the declarations of i and my_array to the start of the function.

After that, and creating a file containing your sample data, it ran fine and created the array data, which is what I expected. And the data was what the sample showed - 9 integers, starting with "8", then "52", "91", ...

So what is different?
I'm compiling with VS on "C only" mode - what are we doing differently? What happens when you run this through the debugger?
 
Share this answer
 
Comments
OriginalGriff 15-Nov-14 11:51am    
The code you have there already does "scan the numbers from a file beginning with the second one" - it reads the first value and uses that as the number of elements to read into an array: 9. The values that go into the array start with the second value: 8, and continue from there.

BTW: Adding comments doesn't change how the code works! :laugh:

So what do you get when you run it?
OriginalGriff 15-Nov-14 12:03pm    
It looks right to me: your text file says, 8 values, starting with 52, 91, ...
and your screenshot shows an array of eight bytes created.

Why not add a second loop to show you the actual values?

//if all working smoothly...
printf("All up and running! Array of %d values created!\n", t_size);
for(i = 0; i < t_size; i++ )
{
printf(" %d : %d\n", i, my_array[i]);
}

Should do it...
CPallini 15-Nov-14 16:55pm    
Good answer, my 5. Now, Sir, where is the question? :-D :-D :-D
Nelek 15-Nov-14 16:59pm    
refer to v1 and v2 ;P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900