473,670 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading and Outputing data from a text file HELP

5 New Member
I am having trouble with a normally simple function, I am trying to read a text file and output what is in the file:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <fstream> // To access a disk file (both input and output)
  5. #include <string> // To use a sequence of characters
  6. #include "Header.h" 
  7. using namespace std;
  8.  
  9. int main() {
  10.  
  11.    string line;
  12.    ifstream readmatrix ("PE ratios.txt"); //Attempts to locate file and open it
  13.    if (readmatrix.is_open())
  14.    // If the file is found and able to be opened the following will happen:
  15.    {
  16.       while (! readmatrix.eof() )
  17.       {
  18.          getline (readmatrix,line);//reads .txt file
  19.          cout << line << endl; // Prints what is found in.txt file 
  20.       }
  21.  
  22.       readmatrix.close();
  23.       readmatrix.clear();
  24.    }
  25.    return 0;
  26. }




It runs with no errors or warnings, however the files charcters are not outputed when the program is executed.

Does anyone have any ideas of where I have gone wrong as its been a while since I last did c++.
Feb 8 '07 #1
3 1789
Ganon11
3,652 Recognized Expert Specialist
Not completely sure. What output are you getting? What does the input file look like?
Feb 8 '07 #2
tariq103
5 New Member
Dont worry about every1, it was me being stupid, not having the text file saved in the correct direcory!!!!
Feb 8 '07 #3
tariq103
5 New Member
Tahnks anyway "Ganon11".
Feb 8 '07 #4

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

Similar topics

6
12726
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
1
7044
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the file... Thank you to all of you who can help me with this one...
1
6749
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but listen up; Reports, the way I look at them, all present data downwards, in this way; TITLE data
4
6656
by: George | last post by:
I am lost on how to do this. I have not worked with C much at all but can understand the basic properties of this language. Could someone please show me or explain to me how to write a function that outputs ASCII PPM files. I need to output a 512 x 512 image containing random noise with the top-most row of pixels red and the left-most pixels blue( instead of the random). Thank you so much for your help it will greatly greatly be...
4
3288
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
4
3259
by: Gaijinco | last post by:
I had a file named nap.in which looks like this: 4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00 Lunch, just lunch.
1
5395
by: JanaB | last post by:
I am writing a code that needs to read in a binary file. At the moment I don't have to do anything with the data, I just need to view the contents to compare its structure with another binary file. Right now all I'm getting in my output is a series of numbers such as: 2-4-73015010000000245-36-12800115011500-1280-1280-12 I adapted my script from a post I saw earlier today from member UnknownBlue who was trying to do a similar thing, but...
1
2116
by: une | last post by:
hey guys, I have this program to do, but I kind of started forst just te read things from the file and then I would go and make the calculation but it is showing some wierd funnky resualts, I dont know why is now outputing what is in the file, this is the program A file called Stock.txt contains information regarding the 9 different stock items carried by FUNNY STUFF RETAIL INC. The file is a repeating sequence of three records such that the...
11
1752
by: googletired | last post by:
Hello, I've been working on this for a days and getting frustrated. Basically i want read a master xml file that references many other xml files and use this information to output an RSS Feed. File to reference. this file is usally quite large and has many categories so it needs to be able to read each category and output a channel then item contents for each article id in the catecory. <?xml version="1.0" encoding="utf-8"?>...
0
8468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8660
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7415
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.