Results 1 to 6 of 6

Thread: Simple C++ error but i don't konw whats going on...newbie

  1. #1

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Question

    Hello everyone...
    im' currenlty reading this book....
    and its called thinking in C++

    well the problem is,
    look at this code..

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <vector>
    #include <conio.h>
    using namespace std;
    int main() {
        vector<string> v;
        ifstream in("FillVector.cpp");
        string line;
        while(getline(in,line))
             v.push_back(line);
        for(int i = 0; i < v.size(); i++)
               cout << ": " << v[i] << endl;
        getch();
        return 0; }
    i get an error that says....

    c:\my documents\c++programs\fillvectandwhitesapces.cpp: In function `int main()':
    c:\my documents\c++programs\fillvectandwhitesapces.cpp:16: implicit declaration of function `int getchar(...)'


    and i also tried other forms like getchar() and using differnet things but still i get an error, like on somes, it says directory wasn't found...

    so what am i doing wrong?

    the code works fine until i try and put the last piece of code in so u have to press a button for it to EXIT,and this is console of coures....

    if u know whats going on, please explain it

    THanks for listening!


  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    It works fine on mine (once I put the [i] that's missing back in of course ).

    Are you using VC++ 6? Try going to Build -> Clean and try compiling it again. If that doesn't work, try it in a new project. I find that sometimes it just gets itself messed up.
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Question Thanks, what do u mean?

    Hey when u said when i placed the [i] back in of course, what do u mean?
    what am i missing?
    and no i'm using DevC++

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Hehe, well it's happened again look When you write the i in brackets like [i] the forum code sees it as an italics tag, so it gets removed and text after it gets changed to italic. It's better to use x or j instead of i when you post.

    The code is fine in VC++ 6 anyway. Try copying the code and making a new .cpp file with the same code in, and try to compile that, see if you get the same errors.
    Harry.

    "From one thing, know ten thousand things."

  5. #5

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Unhappy this SUCKS! it donest work on my compiler, what the heck...

    Okay i get the same error can u tell me another #include and functiont hat will work rather then chget()?

    maybe it just doesn't except that or somthing?::

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    *Shrugs*

    No idea I'm afraid.
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width