Thread: stuck!!!!

  1. #1
    Unregistered
    Guest

    stuck!!!!

    Hi,

    pls give some ideas about this:
    Thanks a lot.......

    1)A function is reading data from text file , that same function is returning 2 values after reading from the file ( so I made inputfile , in the argument list as call by reference (right or wrong)
    if wrong what should be done ......

    funcn defination is :
    Code:
    int  readFromFIle(account database[], ifstream &inputFile)
    { :
       :
        :
     return count ;
    return tempPIN;
    }


    2) when I am calling the above function , in the Main ,how I am suppose to store this 2 variables ??

    Code:
    int Main()
    {
    :
    :
     ??? (variable 1) = readFromFIle( database, inputFile)
     ???(variable2 ) =  readFromFIle( database, inputFile)
    return 0;
    }

    3)I have to use those 2 variables in number of other functions

    Code:
    case 1: NewAccountCreation(database, totalRecord , tempPIN);
    case2 : openExistingAccount(database, totalRecord, tempPIN);
    Are all the methods right?????because I feel my 1st and 2nd part is wrong........

    help!!!!!!!!!

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    A function can't return two different variables at the same time. You could pass them by reference and have the function fill them perhaps.


    Code:
    void  readFromFIle(account database[], ifstream &inputFile, int& count, int& tempPIN)
    { :
       :
        :
    count = 6;
    tempPIN=1234;
    }
    
    
    
    int main()
    {
       // other stuff declared
       int pin;
       int count;
       readFromFile(database, inputFile, count, pin);
    
       return 0;
    }
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Unregistered
    Guest

    thanks a lot.....but one more Q

    I am just grateful to u.......I was able to solve it....
    Thanks a lot.....

    Now there is another silly question:

    1)a function is defined to cancel an account...... but as per my code the record doesnt gets cancelled.....Why??Can u pls enligten me??

    Code:
    void cancelExAccount(Account [], int count ) // count is the total no. of exisiting records in an array
    
    {
     variable declaration ........
    
    for(int i=0; i < DATABASESIZE; i++)
    {	
    		
      if( database[i].name==validName )
      {
         tempName = database[i].Name;
         tempPIN  = database[i].PIN;
            :
            :
         cout<<tempName<<endl;
            :
           :
            :
    }
    
    :
    :
    if(reply=="Y" || reply=="y")
    {
    						
                 database[count-1].Name ;
                 database[count-1].PIN;
                 database[count-1].bal;
                  :
                  :
    
    cout << "Account cancelled"<<endl;
    cout << "\n\n";
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 10-23-2006, 07:22 PM
  2. string array stuck:(
    By mass in forum C Programming
    Replies: 18
    Last Post: 05-22-2006, 04:44 PM
  3. Program stuck in infinite loop-->PLEASE HELP
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 03-26-2005, 12:40 PM
  4. Stuck on random generating
    By Vegtro in forum C++ Programming
    Replies: 3
    Last Post: 10-01-2003, 07:37 PM
  5. stuck ky
    By JaWiB in forum Tech Board
    Replies: 2
    Last Post: 06-15-2003, 08:28 PM