If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Programming question...

I couldnt quite figure out where to ask this question, since there isint a Newbie Programming area, so I figured here was the safest place.

I'm writing a program in c which determines the volume of cylinders made from PVC. I have three large arrays that store the Inside Diameter of Schedule 40,80, and 120 pipe. Is there an easier way than having such large arrays, perhaps reading the values from a file? I'm still very new to C so any help is greatly appreciated

Hardcoding data in usually not (ok.. never...) a good idea. The best place for data is in a database which you will query at runtime.

However, if the program you are making isn't meant to used in a production environment, you could go with an easier option like storing that data in a file (like dspeidel suggested).

Of course the really easiest option is to hardcode your data as arrays in your program, but this really isn't ideal. (Example: if any of that data changes for any reason, you'll have to recompile the program. It might be acceptable for you, but if the program is used by other users, that's unacceptable...)

If you care more about efficient memory management, I would recommend using pointers to create a linked-list rather than using arrays. Arrays, for the most part, are statically allocated, and you then have the problem that you either have too much space in the array (wasting valuable memory) or you don't have enough (and you'll end up with an overflowing buffer, if you don't handle the checks properly). Dynamically allocating the array is a possibility, but it's a lot more coding. In my opinion, linked lists would be the way to go.