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. why compile no error,but when running note"unable to open input file"

why compile no error,but when running note"unable to open input file"

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 1 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.
  • V Offline
    V Offline
    vividtang
    wrote on last edited by
    #1

    #include #include #include int main() { using namespace std; ofstream outfile("F:\myoutfile.txt"); ifstream infile("F:\myinfile.txt"); if(!infile) { cerr<<"error,unable to open input file\n"; return -1; } if(!outfile) { cerr<<"error,unable to open output file!\n"; return -2; } string word; while(infile>>word) outfile<

    M R 2 Replies Last reply
    0
    • V vividtang

      #include #include #include int main() { using namespace std; ofstream outfile("F:\myoutfile.txt"); ifstream infile("F:\myinfile.txt"); if(!infile) { cerr<<"error,unable to open input file\n"; return -1; } if(!outfile) { cerr<<"error,unable to open output file!\n"; return -2; } string word; while(infile>>word) outfile<

      M Offline
      M Offline
      mcsherry
      wrote on last edited by
      #2

      have you tried using double backslash in the path name as in C++ and C a single backslash followed by a letter is a special case, e.g. \n is newline hth

      V 1 Reply Last reply
      0
      • M mcsherry

        have you tried using double backslash in the path name as in C++ and C a single backslash followed by a letter is a special case, e.g. \n is newline hth

        V Offline
        V Offline
        vividtang
        wrote on last edited by
        #3

        ofstream outfile("F:\\test\\myoutfile.txt"); ifstream infile("F:\\test\\myinfile.txt"); ok!

        1 Reply Last reply
        0
        • V vividtang

          #include #include #include int main() { using namespace std; ofstream outfile("F:\myoutfile.txt"); ifstream infile("F:\myinfile.txt"); if(!infile) { cerr<<"error,unable to open input file\n"; return -1; } if(!outfile) { cerr<<"error,unable to open output file!\n"; return -2; } string word; while(infile>>word) outfile<

          R Offline
          R Offline
          Rafael Fernandez Lopez
          wrote on last edited by
          #4

          Compiler doesn't looks for your files... that is not a compiler error !!!. is not a sintaxis error... because is a string... You know what I mean ?? ;)


          Written by: Rafael Fernández López.

          Visit: http://www.maestroprogramador.com

          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