How big is the file? If you can read it all into memory, it'll make life a lot simpler:

string[] lines = File.ReadAllLines("file.txt");

// Could use lines[lines.Length - 1] but LINQ makes it simpler...
string lastLine = lines.Last();

IEnumerable&lt;string&gt; otherLines = lines.Skip(1).Take(lines.Length - 2);


So that's the "getting the data out of a file" part. For the database part, you haven't really given us enough information to help you. You need to determine how you're going to do database access (straight ADO.NET, LINQ etc) and then read tutorials on that topic. There are plenty around.

Load data from specific lines in a text file into SQL using C#
I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:

# (1)
for k in range(4..20):
  # (2)
  input = generate 2**k random points
  for variant in variants:
    benchmark the following call
    run variant on input array
  # (3)


Is it possible to reset the whole heap management at (2) to the state it had at (1)? All memory allocated on the heap that was allocated during the program is guaranteed to be freed at (3).

I am using g++ 4.3 on Linux.

Edit: I understand that there is no real garbage collection in C/C++. I want to force the memory allocation to join adjacent empty chunks of memory it has in its free list at (2).
