| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Infile problems, functions call problems
I have a problems calling a function
this is my code that is causing problems for the call I get sytax error before ']' token load(gpa[], students[], size); Is somethings wrong with this code?????? And for this infile problem, I have to read in a infile and outfile, but what should I use for infile, because I try to use infile>> and it says that infile is undeclared. Thanks |
|
#2
|
|||
|
|||
|
firstly, to send to a function I would use a pointer(IMO), and for in the infile you need to do alot more than just infile here is a sample from an old code I did(some things have been deleted for the sample :P)
Code:
#include <iostream>
#include <fstream>
#include "foodClass.h"
using namespace std;
void Food::readFile()
{
int length = 0;
foodFacts foodCapacity;
foodCapacity.name = new char [101];
foodCapacity.catagory = new char [50];
ifstream readIn;
head = NULL;
readIn.open("fooddb.db");
if (! readIn) {
cerr << "There was an error opening the data." << endl;
exit(1);
}
readIn.get(foodCapacity.name, 100, ';');
readIn.ignore(1000, ';');
while ( ! readIn.eof() ) {
readIn.get(foodCapacity.catagory, 100, ';');
readIn.ignore(1000, ';');
readIn >> foodCapacity.calories;
readIn.ignore(100, ';');
}
readIn.close();
}
|
|
#3
|
|||
|
|||
|
I'm still having problems with calling the functions. How am I supposed to use a pointer?
My array is 10 elements long. The function I'm calling will load the array with data from a file. Maybe somebody could show me how to call a function with an array as a parameter?? I really don't what I'm doing wrong. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Infile problems, functions call problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|