C Board  

Go Back   C Board > General Programming Boards > Networking/Device Communication

Reply
 
LinkBack Thread Tools Display Modes
Old 04-17-2004, 02:48 PM   #1
Registered User
 
Join Date: Mar 2004
Posts: 220
Question CD-ROM Read

Anyone have any good guides on CD-ROM reading? I have a new interest in this..and I have no idea where to turn too. What i'm looking for is to read a text file on a disc and display it on the screen in a console window..that sort of a thing. Any idea how this can be done? If so please state your source/anything else interesting you want to note about CD-ROM reading, thank you for your assistance It is very much appreciated.
__________________
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Tronic is offline   Reply With Quote
Old 04-17-2004, 03:01 PM   #2
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
Just open the file as you would any other, specifying its full path.

Eg, assuming your CD is drive F
fp = fopen("f:\\myfile.txt", "r");
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Old 04-17-2004, 03:04 PM   #3
Registered User
 
Join Date: Mar 2004
Posts: 220
Could you explain your code please?

I'm new to fopen.

Thank you for your reply by the way I appreciate it.
__________________
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Tronic is offline   Reply With Quote
Old 04-17-2004, 07:01 PM   #4
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
Before I explain in detail, what language are you intending to write this in? My sample was C, but no point in telling about it if you're not writing in the same language.

Anyway, whatever language, just open the file as you would any other, giving the full path name to it.
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Old 04-17-2004, 09:28 PM   #5
Registered User
 
Join Date: Mar 2004
Posts: 220
Thank you And it was C++.
__________________
OS: Windows XP Pro CE
IDE: VS .NET 2002
Preferred Language: C++.
Tronic is offline   Reply With Quote
Old 04-18-2004, 05:09 AM   #6
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
Code:
#include <iostream>
#include <fstream>

using namespace std;

int main(void)
{
  ifstream fs("f:\\myfile.txt");
  string st;
  
  while (getline (fs, st, '\n'))
  {
    cout <<st <<endl;
  }
  
  fs.close();
  return(0);
}
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknown Memory Leak in Init() Function CodeHacker Windows Programming 3 07-09-2004 09:54 AM
mp3 players vs mp3 cd players Geo-Fry A Brief History of Cprogramming.com 5 12-06-2003 09:22 PM
Pointer's xlordt C Programming 13 10-14-2003 02:15 PM
Read Array pro!!Plz help!! Supra C Programming 2 03-04-2002 03:49 PM
Help! Can't read decimal number Unregistered C Programming 2 09-07-2001 02:09 AM


All times are GMT -6. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22