![]() |
| | #1 |
| Registered User Join Date: Mar 2004
Posts: 220
| It is very much appreciated.
__________________ OS: Windows XP Pro CE IDE: VS .NET 2002 Preferred Language: C++. |
| Tronic is offline | |
| | #2 |
| End Of Line 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 | |
| | #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 | |
| | #4 |
| End Of Line 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 | |
| | #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 | |
| | #6 |
| End Of Line 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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |