Thread: string issue

  1. #1
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    string issue

    i feel like a real newbee for this one.
    I'm using the following code in my program, but it will not link.
    Code:
    #include<string.h>
     
    int main(int argc, char *argv[])
    {
        string stFileName(argv[2]);
        string stProgramName(argv[0]);
     
        cout<<"File Name: "<<stFileName<<endl;
        cout<<"Program Name: "<<stProgramName<<endl;
     
        return (0);
    }
    error c2679 '<<':no operator found which takes a right-hand operand of type 'std::string'(or there is no acceptable conversion)

    ?? why is this erroring ??
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    As it is, you haven't included the right headers (it's <string>, not the C <string.h> header; where's <iostream>?). You have probably also left out other relevant stuff, because as it is you shouldn't get even this far.

  3. #3
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    thanks

    correcting the string.h to string fixed the issues.
    the other code was left out intentionally.
    sorry i do not have the capability of cut and paste, so limiting the amount i can type. working on laptop and work pc at same time.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please check my C++
    By csonx_p in forum C++ Programming
    Replies: 263
    Last Post: 07-24-2008, 09:20 AM
  2. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  3. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM