473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to open text file using c++

I have written a program that can open and read a text document. I compiled the code with no errors but I am still not able to open the text document. I have checked that the location where the text file is kept has full access.The text file resides in inFile.open("C:\\Users\LJ\\Desktop\\CPPExamples\\S ection4\\Delta_T\\Test01.txt"); where Delta_T is a folder. Please view my code.

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
ifstream inFile;
inFile.open("C:\\Users\LJ\\Desktop\\CPPExamples\\S ection4\\Delta_T\\Test01.txt");

//Check for error

if (inFile.fail())
{
cout << "Error Opening File";
}
else{
string item;
// while(inFile >> item)
while(getline(inFile, item))
{
cout << item << endl;
}
inFile.close();
}
system("pause");
}
Apr 2 '19 #1
1 1022
dev7060
630 Expert 512MB
I ran the code in Code::Blocks, everything worked fine for me. What IDE are you using?
Apr 2 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Simon Verona | last post by:
Not sure if this is the best group... it may be better off in one of the ADO groups, but I'm sure somebody here knows the answer: I'm trying to load up a text file using ADO.net, as follows: ...
0
by: Sasie7679 | last post by:
Dear All, We have a requirement to open any file using a specific application and showing it within a activex control. For example, bmp file can be shown in Internet explorer, paint brush, photo...
1
by: neveen | last post by:
i want to open and read text file using j2me that can run on mobile 6630 then i want to make button called read that when pressed the data inside text display
2
by: sajidali | last post by:
i am trying to append a text file using c#. when i executes my application i writes to the text file using more then one functions. i want to append file only during execution of programe. next time...
3
by: tivicoo | last post by:
I have a 16 bit array called ADData, and i want to save this array to a text file using C#. i tried to use different codes that i located online but when i open the saved data on notepad the data...
1
by: sydmil | last post by:
Hello, I am relatively new to VB6 and I was wondering if anyone could show me an example of a VB6 code to do the following: Open text file (which is a column of numbers) in excel - comma...
4
by: kshw | last post by:
Hi, I'm trying to remove non-stop words from a text file using regular expresions but it is not working. I used something like ('^?or') in order to avoid removing (or) from the mibble of words...
1
by: sanchit007 | last post by:
How can i open any file using voice command. Means that i say anything like open internet it perform a task....... How we can do through java programming
1
by: yanze | last post by:
This is actually a question on how to import Open Office file record into an SQL Database. We have successfully exported an SQL data from our branch's database into an Open Office file using our...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.