C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 5th, 2005, 09:14 PM
bigphil bigphil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 bigphil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 39 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 5th, 2005, 09:44 PM
l3luemage l3luemage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 l3luemage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 47 sec
Reputation Power: 0
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();
}

Reply With Quote
  #3  
Old April 6th, 2005, 03:09 PM
bigphil bigphil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 2 bigphil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 39 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Infile problems, functions call problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT