Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,420 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,988 people online right now. Registration is fast and FREE... Join Now!




file handling

 
Reply to this topicStart new topic

file handling, How to open a file to read

chellappa
13 Jan, 2008 - 10:08 AM
Post #1

New D.I.C Head
*

Joined: 13 Jan, 2008
Posts: 2

Whenever I try to open a file in read mode I come accross an error message (Unable to open ...) Kindly guide me with one simple example program that opens a file and reads a specified line
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: File Handling
13 Jan, 2008 - 10:16 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,260



Thanked: 227 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Did you try searching this site? We have tons of posts for reading and writing files with full examples. There are also many examples of file reading online through a Google search.

Focus your efforts around ifstream, ofstream classes and the getline() method.

Now if you have some code that is not working correctly, please do post it with your specific question and I am sure we can guide you as to where you are going wrong.

smile.gif
User is offlineProfile CardPM
+Quote Post

carltech
RE: File Handling
14 Jan, 2008 - 02:41 PM
Post #3

New D.I.C Head
Group Icon

Joined: 19 Oct, 2007
Posts: 42


Dream Kudos: 25
My Contributions
Also try to make sure that the file is located within the same folder as the rest of the project unless you want to specify a path to the file.
User is offlineProfile CardPM
+Quote Post

quim
RE: File Handling
14 Jan, 2008 - 03:55 PM
Post #4

D.I.C Head
Group Icon

Joined: 11 Dec, 2005
Posts: 145



Thanked: 2 times
Dream Kudos: 350
My Contributions
Check this site for explanation of Input / Output with file:
http://www.cplusplus.com/doc/tutorial/files.html
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 04:16AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month