I'm getting an error and I don't understand why. I'm reading in a file of numbers that I need to convert from characters to a number that I store in an array. Then I need to fill the rest of the array with zeros.
inputFile >> num; formatted input skips whitespace characters, so condition (num != '\n') will always be true. Use unformtted input, say, .get() member function.
Also: number[i] = num + '0'; I think, you meant −, not +
Ok I did that and it works. I have another question though. If I wanted to call the function multiple times to read in different numbers, but not start at the beginning of the file every time how would I do that? or would I have to read in every number at once and pass all of the arrays?
Make your function to accept reference to istream as one of the parameters. You will open file in calling function and will just call function again on already existing file.