Thread: iostream help...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    48

    iostream help...

    Using g++ 2.95.4. When trying to compile this function:
    void main()
    {
    float mean, numAbove = 0;
    ifstream nmbrs;
    nmbrs.open("nmbrs.txt", ios::in);
    .......
    nmbrs.clear();
    nmbrs.seekg( 0, ios::beg );
    mean = mean / 100.0;
    numAbove = numAboveAverage(nmbrs, mean);
    .........
    }


    float numAboveAverage(istream & nmbrs, float mean)
    {
    float AboveNum;
    }


    I get the following error:
    project3-1.cpp:62: implicit declaration of function `int numAboveAverage(...)'
    project3-1.cpp:62: warning: cannot pass objects of type `ifstream' through `...'

    Im lost, anyone have any input? Thanks in advance.
    Last edited by guda; 10-02-2002 at 11:14 AM.

  2. #2
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    I can't really see, where is the mistake here.
    I have overflow the text and noticed, that you haven't posted the complete code.

    question:

    Have you done a declaration for your datatypes???????


    -> And the is something about declarations in the error message!!!!

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    48
    I just added the datatypes to the top of the screen... should I post all the code? 77 lines total as of now!.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    48
    Actually the entire program works, until that function is called. I I comment out the call to the numAboveAverage() it works w/o error.

  5. #5
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380

    Re: iostream help...

    Originally posted by guda
    void main()

  6. #6
    Registered User
    Join Date
    Oct 2002
    Posts
    48
    OK, so whats your point... was looking for help not pretty little sarcastic cartoons.

  7. #7
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    it's ironic because I gave a lecture to my classmates today about why void main() is bad practice; I'm just saying that I feel like hurling myself off of a building upon seeing void main() after that 3-hour class

    Sorry

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >project3-1.cpp:62: implicit declaration of function `int numAboveAverage(...)'
    I'm not familiar with G++ error messages, but this appears as if you forgot to prototype numAboveAverage, the compiler assumed a function returning int and taking any number of arguments, and didn't like when you passed it an ifstream object.

    >OK, so whats your point... was looking for help not pretty little sarcastic cartoons.
    I thought it was cute. ^_^ And BMJ's advice was sound, even if it wasn't the help you were looking for.

    -Prelude
    My best code is written with the delete key.

  9. #9
    Shadow12345
    Guest
    that cartoon is sweet, lmao



    ahahahahahahaha


    ahahahahahahaahahash



    sweet

  10. #10
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Salem's avatar better shows the void main hatred:
    Attached Images Attached Images iostream help...-salemavatar-gif 

  11. #11
    Registered User
    Join Date
    Oct 2002
    Posts
    48
    ahh.. prototype... schmack, my mistake. I did like the cartoon, however I didnt know whether or not he was telling me to take a jump off a building or what .. this being my first post I was like what the?.. :0), anyways thanks.

  12. #12
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Oh! No no no! I would never tell a first time poster to jump off a building! I love new people on the board!

    Just imagine speaking and arguing for 3 hours about void main() vs. int main()

    Upon seeing void main() I wanted to throw myself off a building into oncoming traffic

  13. #13
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Just imagine speaking and arguing for 3 hours about void main() vs. int main()
    You have to be more forceful, it takes me at most 30 seconds to beat reality into someone about void main, and even then most of the time is spent walking to my library, pulling out the ISO Standard, and flipping to the (bookmarked!) page. Every once and a while I hit them with the book, but only for 2nd+ offenses.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drieving from iostream
    By Thantos in forum C++ Programming
    Replies: 8
    Last Post: 06-23-2004, 04:57 PM
  2. iostream & hex?
    By dmlx90 in forum C++ Programming
    Replies: 0
    Last Post: 05-22-2002, 11:51 PM
  3. DJGPP Doesn't include IOSTREAM!!!!!!!!!!!
    By Frenchfry164 in forum Game Programming
    Replies: 12
    Last Post: 10-27-2001, 12:27 PM
  4. << in iostream
    By badman in forum C++ Programming
    Replies: 8
    Last Post: 10-18-2001, 10:19 PM
  5. Is there a C iostream?
    By Khisanth in forum C Programming
    Replies: 1
    Last Post: 09-05-2001, 12:34 AM