Results 1 to 4 of 4

Thread: declaring and using strings

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    declaring and using strings

    I drivin myself up the wall here... I'm using vc++... and all i am tryin to do is declare and use a string variable....

    #include <iostream>
    #include <string>

    void main()
    {
    string firstBinaryDigit;
    string secondBinaryDigit = "h";
    cout << "Enter first binary number";
    cin >> firstBinaryDigit;
    cout << "\nEnter second binary number";
    cin >> secondBinaryDigit;
    }

    but i get this error... it won't recognize string...
    :\Windows\Cpp1.cpp(6) : error C2065: 'string' : undeclared identifier


    whats up ?

    I realize there is Cstring class, but I haven't been able to get that to recognize either.... (plus I need to use the std String class since its intended to run on a unix system...)

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    PHP Code:
    #include <iostream> 
    #include <string>

    using namespace std;

    void main() 

    string firstBinaryDigit
    string secondBinaryDigit "h"
    cout << "Enter first binary number"
    cin >> firstBinaryDigit
    cout << "\nEnter second binary number"
    cin >> secondBinaryDigit

    try that.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    :\Windows\Cpp1.cpp(3) : error C2871: 'std' : does not exist or is not a namespace
    C:\Windows\Cpp1.cpp(6) : error C2065: 'string' : undeclared identifier

    and thats what i get....

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I removed the .h from the include header statements, and now it worked... man i hate this language... but thanks very much.. it works now...

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