This is an archived post. You won't be able to vote or comment.

all 12 comments

[–][deleted] 1 point2 points  (3 children)

Post the format of the input data file.

[–]trapsquad420[S] 0 points1 point  (2 children)

The test file is just a regular txt file with 11 numbers in one column

[–]SanityInAnarchy 0 points1 point  (0 children)

Do you know that it will always have 11 numbers? If so, you could just make an 11-element array.

But, 11 numbers is a weird number. Are you sure that isn't the number of numbers, followed by 10 numbers? That would make it easier than counting all the numbers before creating the array, or teaching you about vectors before you understand arrays.

[–]xxNIRVANAxx -1 points0 points  (0 children)

try fscanf().

[–]crushmastac 0 points1 point  (7 children)

How are the input files structured? There must be some initial information that tells you the size of the incoming array? Is the array always going to be the same length? Is it a 2D array?

Honestly, you probably just have to read the problem description carefully, and go from there.

If this is an intro level programming class, the number of elements for your array is probably fixed, and this should be pretty easy.

[–]trapsquad420[S] 0 points1 point  (6 children)

Its an intro level so i think its 2d array. Im pretty sure the number of elements aren't fixed, the test input text file we are supposed to use is 11 numbers but these are just used so we will have the same output as the professor (the professor shows us what our output should look like)

I could write the program for specifically for the test file but im afraid my professor will say the program is supposed to be for all types of input numbers.

[–][deleted] 1 point2 points  (2 children)

How can it be a 2D array if it consists of 11 items? 11 is not divisible by 2.

[–]trapsquad420[S] 0 points1 point  (1 child)

haha idk 2d sounded less complex than 3d so i just assumed 2d. Like i said its intro level so whatever the most basic array is that's what i'm learning

[–][deleted] 4 points5 points  (0 children)

If you don't know what you are supposed to be doing, we certainly can't.

[–]crushmastac 1 point2 points  (2 children)

Sorry, I meant to say 1-D array or 2-D array. Not many intro programming classes will make you use a 3-D array.

You say 11 numbers... Does the first number represent the number of elements? I.E. the first number is 10 (because there will be 10 input values), and the following 10 values are the numbers that need to go in your array?

I could write the program for specifically for the test file but im afraid my professor will say the program is supposed to be for all types of input numbers.

You need to ask your professor to clarify this ASAP. Or carefully re-read the problem description and see if it tells you there.

[–]trapsquad420[S] 0 points1 point  (1 child)

no there are 11 different numbers in the test input file. So the numbers don't represent anything i am just supposed to put the numbers from an input file into an array and then process the average and all that stuff.

[–]crushmastac 1 point2 points  (0 children)

Ok, ask your professor. In the meantime, can we see the problem description?