View Single Post
  #1 (permalink)  
Old 10-11-2006, 05:20 PM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 11
hoser2001 is on a distinguished road
Default Dyanmically setting the size of an array

I am given an inpute file that looks like this:

1)N - where N is an integer
2)name1
name2
.
.
nameN-1
nameN
a matrix of values of size NxN

so for example this could be a possible input file:

5
Adam
Bonnie
Clyde
Drake
Emily
0.0 23.7 49.5 9999.9 9999.9
23.7 0.0 16.9 39.4 9999.9
49.5 16.9 0.0 9999.9 53.6
9999.9 39.4 9999.9 0.0 9999.9
9999.9 9999.9 53.6 9999.9 0.0

I need to take this in as an input and be able to:
1) create two arrays of the fashion: float array[n][n] where n is the integer at the beginning
2) create an array to hold the names so something like: char array[n][20]

The problem is I don't know how to do this dynamically, how do I create arrays based on a value I don't know until i suck in the input value????

Any suggestions would be helpful.
Reply With Quote

Sponsored Links