ok im doing this for school and he says i need to read a file with an array and load that numbers of the file using a function so this is what i have so far:
it seems to bomb at the thought of istream being placed in a function and passed through??? but as far as i know variable types can always be passed through at least thats my understanding. i dont see why it would be bombing on it it also doesnt seem to like if i put file_data[99] when i call it in main with the print_array function so i just leave it blank. why does it do that? doesnt make sense to me anyway.
c:\skool\Program 1\Program 1\Program 1.cpp(27): error C2664: 'load_array' : cannot convert parameter 1 from 'std::ifstream' to 'std::ifstream'Code:#include "stdafx.h" #include <fstream> #include <string> #using <mscorlib.dll> using namespace std; using namespace System; int load_array(ifstream in); void print_array(int file_data[99],int count); int main() { int count = 0; int file_data[99]; ifstream in; in.open("prog1.dat"); while(!in.eof()) { file_data[count] = load_array(in); //THE LINE IT ERRORS ON count++; } in.close(); print_array(file_data,count); return 0; } int load_array(ifstream in) { int dummy; in >> dummy; return dummy; } void print_array(int file_data[99],int count) { for(int i = 0;i <= count;i++) cout << file_data[i]; }
oh and yea some of those headers are C++.net headers i know but im using that compiler and since hes running it im not making portable code just using the .net framework version. though in this class he said if you know standard C++ because we used to teach that and some students still know it if you know it you can use it and i much rather use that over C++.net anyday or year. plus hes using standard C++ file handling anyway cause .net sucks with it lol and yea it doesnt seem to like me to remove those headers.