2 Replies - 1359 Views - Last Post: 08 October 2012 - 09:03 AM Rate Topic: -----

#1 beastmode68  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-October 12

I am having trouble reading from a file in c++

Posted 08 October 2012 - 07:06 AM

Hey i am trying to read the first line from a file and to read it out the the printout screen. I am new to programming so I am not too sure what i am doing wrong.
Attached Image
Is This A Good Question/Topic? 0
  • +

Replies To: I am having trouble reading from a file in c++

#2 jimblumberg  Icon User is online

  • member icon


Reputation: 4232
  • View blog
  • Posts: 13,293
  • Joined: 25-December 09

Re: I am having trouble reading from a file in c++

Posted 08 October 2012 - 07:16 AM

First post your code inside code tags, not a picture of your code. Next you should insure your file opened correctly. See the documentation for ifstream.open().

Jim
Was This Post Helpful? 1
  • +
  • -

#3 Coding Mash  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 26
  • Joined: 29-September 12

Re: I am having trouble reading from a file in c++

Posted 08 October 2012 - 09:03 AM

Your file should exist in the root directory in which you are working. After opening the file, make sure to check whether the file has opened or not. Use the function is_open () for that purpose.
As mentioned above, check the documentation of ifstream library functions and file handling input method.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1