CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    1

    Rookie Debugging

    Simple unterminated constant. The problem i think is with the if statement.

    int main ()
    {
    string name;

    string address;

    string phonenumber;

    string name;
    cout<< "What is your name? ";
    cin>> name;
    If name="What is your name?";

    name="Amy Tay";

    address="3102 Peterboro Drive";

    phonennumber="330-678-7557";

    cout<<"\t"<<name<<\n";

    cout<<"\t"<<address<<\n";

    cout<<"\t"<<phonennumber<<\n";
    }

    #include <iostream.h>
    using namespace std;
    int main()
    int age, float Weight;
    age=26;
    weight=180;
    cout<<"My age is"<<age<<"and my weight is"<<weight<<"pounds."


  2. #2
    Join Date
    Apr 2001
    Posts
    1

    Re: Rookie Debugging

    I'm a rookie as well, but one thing I saw in that code was your use of header file.

    You used:
    #include <iostream.h
    using namespace std;

    I know that gives me an error when I build it.

    If you are going to code:
    using namespace std;

    Then you want to code:
    #include <iostream>

    rather than:
    #include <iostream.h


    It doesn't compile with the error you mentioned, but will give a different error, so I'm not sure if that will help you or not.

    BTW, I use vc++ so if you are using a different compiler, then it may not cause an error... not sure.

    p.s. I would recommend using:
    #include <iostream>
    using namespace std;

    over the .h method because .h was deprecated about 5 years ago.

    Hope it helped a bit.


  3. #3
    Join Date
    Jan 2001
    Location
    Germany, Bavaria
    Posts
    61

    Re: Rookie Debugging

    cout<<"\t"<<name<<\n";
    cout<<"\t"<<address<<\n";
    cout<<"\t"<<phonennumber<<\n";

    must be ... <<"\n" or better << std::endl;

    i also recommend using <iostream> instead of <iostream.h>, and 'using namespace std;', as the other poster suggested.

    Chris




    ----
    http://www.crupp.de

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

Featured