CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Location
    wv
    Posts
    3

    error c2678:binary'>>'...

    i am trying to learn c++ from a book, c++ primer plus, and visual studio 2010. i am stuck on an exercise in chapter 5 where i am suppposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:
    #include <iostream>
    int main()
    {
    using namespace std;
    int num;
    int total = 0;
    int x;
    cout << "Enter number: ";
    cin >> num;
    while (num != 0) { total = total + num;
    cout << total << endl;
    cin >> "Enter a number "; //this is where the error is
    cin >> num;
    }
    cin.get();
    return 0;
    }
    the full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++? any help is appreciated.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: error c2678:binary'>>'...

    Code:
    cin >> "Enter a number ";   //this is where the error is
    How can you enter data into a string literal? Look carefully at your code. Why are you using cin here?

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Feb 2013
    Location
    wv
    Posts
    3

    Re: error c2678:binary'>>'...

    got it and feel like an idiot. it took me three days to figure out the other one, but this one used a cin instead of cout.

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: error c2678:binary'>>'...

    Regarding your question about c++ and Visual c++.

    Visual c++ is an IDE for programming in c++ (the language) so there is a difference but probably not the one you had in your mind when asking? There are also some things that MS support that are specific for them but those can be disabled if you want. Open the Project properties, select C/C++, Language and you find it. See here http://msdn.microsoft.com/query/dev1...SIONS)&rd=true
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Feb 2013
    Location
    wv
    Posts
    3

    Re: error c2678:binary'>>'...

    thanx for all the help. it's crazy how sometimes you can get so deep into it and miss the little stuff like this. and the reason i was asking about the differences was so that i could start writing apps for blackberry. i didn't want to be stuck with non portable code. i will disable the ms specific things so i don't run into that problem.

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