473,396 Members | 2,013 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,396 software developers and data experts.

printing out data from a user-defined text file

So, I'm writing a program for my beginning C++ class and I am VERY
confused as to how to get the user defined file name opened and read
the data i need to from it.

i know i have print to the user what i want them to enter,

cin the filename

but where i get stuck is when it comes to inStream because if we don't
know the predetermined name of the file what goes in the quotes?

Sep 28 '06 #1
1 2383

<am************@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
So, I'm writing a program for my beginning C++ class and I am VERY
confused as to how to get the user defined file name opened and read
the data i need to from it.

i know i have print to the user what i want them to enter,

cin the filename

but where i get stuck is when it comes to inStream because if we don't
know the predetermined name of the file what goes in the quotes?
Don't use quotes. Use the object into which the file
name was stored via cin.

std::string name;
std::cout << "File name? ";
std::cin >name;
std::ifstream infile(name.c_str());

Admittedly, it would be nicer if the 'ifstream'
constructor took a std::string argument directly,
why this wasn't done has been the subject of
past discussions here, you can check the archives
if interested.

-Mike
Sep 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: owyn | last post by:
Our work group has migrated to the .NET environment from some differing back grounds. I am the newest member of the group so I am stuck with the ASPX pages. I am doing the code behind in C#. Our...
16
by: J. B. Moreno | last post by:
I read the faq, and it mentions that IE 4 on windows requires setting a printing option to allow background colors to be printed. Things change, life goes on, other browsers come into...
5
by: VMI | last post by:
I have a BMP image (the form is also in PDF) that contains a scanned copy of a paper form that we need to fill out. Is it possible to use this image in my application so that the application can...
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
4
by: IntraRELY | last post by:
Hello All, I am developing a Web Application in VB.NET. We are printing checks from a IE 6.0. Here are our requirments: 1. Checks will be printed on pre-printed stock, so we must format the...
1
by: CM | last post by:
Hi, I'm thinking about writing .net codes (asp.net, vb.net) for printing management, such as keep tracking of who prints what on when...etc. The app will need to find all available network...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
0
by: Tull Clancey | last post by:
Issue 1. I'm currently writing an app that requires several different label sizes, although in most cases only one size will be used. I want my app to tell the printer driver what size of label...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.