Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. opening a file for output

opening a file for output

Scheduled Pinned Locked Moved C / C++ / MFC
c++ioshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    klutez123
    wrote on last edited by
    #1

    i have to open ADDRESS.DAT i used in a previous assignment, i put the file in the same project folder as this assignment but i keep getting an error. The assignment is to open the ADDRESS.DAT file and output it to the screen: the error: c:\documents and settings\lutyk7\desktop\projects\project 8-3\project 8-3\project 8-3.cpp(75) : error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_ostream<_Elem,_Traits>' (or there is no acceptable conversion) the code: #include "stdafx.h" #include #include #include #include // The one and only application object CWinApp theApp; using namespace std; /****************************************** * M A I N * ******************************************/ int main() { string name, address, city, state, x; ofstream outfile; //Declare file stream name outfile. ifstream infile; cout<<"Please enter your name: "; getline(cin, name); cout<<"Please enter your address: "; getline(cin, address); cout<<"Please enter with city: "; getline(cin, city); cout<<"Please enter your state: "; getline(cin, state); cout<<"Enter your zipcode: "; cin>>x; outfile.open("ADDRESS.DAT",ios::app); //Open file for output. if(outfile) { outfile<> endl; cout << address >> endl; cout << city >> ", " >> state >> " " >> x >> endl; cout << name << endl; cout << address << endl; cout << city << ", " << state << " " <

    T B 2 Replies Last reply
    0
    • K klutez123

      i have to open ADDRESS.DAT i used in a previous assignment, i put the file in the same project folder as this assignment but i keep getting an error. The assignment is to open the ADDRESS.DAT file and output it to the screen: the error: c:\documents and settings\lutyk7\desktop\projects\project 8-3\project 8-3\project 8-3.cpp(75) : error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_ostream<_Elem,_Traits>' (or there is no acceptable conversion) the code: #include "stdafx.h" #include #include #include #include // The one and only application object CWinApp theApp; using namespace std; /****************************************** * M A I N * ******************************************/ int main() { string name, address, city, state, x; ofstream outfile; //Declare file stream name outfile. ifstream infile; cout<<"Please enter your name: "; getline(cin, name); cout<<"Please enter your address: "; getline(cin, address); cout<<"Please enter with city: "; getline(cin, city); cout<<"Please enter your state: "; getline(cin, state); cout<<"Enter your zipcode: "; cin>>x; outfile.open("ADDRESS.DAT",ios::app); //Open file for output. if(outfile) { outfile<> endl; cout << address >> endl; cout << city >> ", " >> state >> " " >> x >> endl; cout << name << endl; cout << address << endl; cout << city << ", " << state << " " <

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      klutez123 wrote:

      cout << name >> endl;

      what the hell is this ??? with cout, use only <<


      [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

      1 Reply Last reply
      0
      • K klutez123

        i have to open ADDRESS.DAT i used in a previous assignment, i put the file in the same project folder as this assignment but i keep getting an error. The assignment is to open the ADDRESS.DAT file and output it to the screen: the error: c:\documents and settings\lutyk7\desktop\projects\project 8-3\project 8-3\project 8-3.cpp(75) : error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_ostream<_Elem,_Traits>' (or there is no acceptable conversion) the code: #include "stdafx.h" #include #include #include #include // The one and only application object CWinApp theApp; using namespace std; /****************************************** * M A I N * ******************************************/ int main() { string name, address, city, state, x; ofstream outfile; //Declare file stream name outfile. ifstream infile; cout<<"Please enter your name: "; getline(cin, name); cout<<"Please enter your address: "; getline(cin, address); cout<<"Please enter with city: "; getline(cin, city); cout<<"Please enter your state: "; getline(cin, state); cout<<"Enter your zipcode: "; cin>>x; outfile.open("ADDRESS.DAT",ios::app); //Open file for output. if(outfile) { outfile<> endl; cout << address >> endl; cout << city >> ", " >> state >> " " >> x >> endl; cout << name << endl; cout << address << endl; cout << city << ", " << state << " " <

        B Offline
        B Offline
        benjymous
        wrote on last edited by
        #3

        klutez123 wrote:

        C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_ostream<_Elem,_Traits>' (or there is no acceptable conversion)

        There's your problem, you're trying to get input from an output stream

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups