473,387 Members | 1,512 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,387 software developers and data experts.

how can input 5 datas in a file an then output all tthem.

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

using namespace std;

// this program contains an error

int main()
{
ifstream ifs("data.txt");
string name;
cout<<"enter the names:"<<endl;
for(int i=0;i<6;i++)
{
cin>>name;
}
// error in stream test
while(!ifs.eof())
{
cout<<name<< endl;
}

system ("pause");
return 0;
}
Jan 6 '12 #1
2 1198
while(!ifs.eof())
{
cout<<name<< endl;
}
this is the problem, it reads through the file non stop
Jan 6 '12 #2
weaknessforcats
9,208 Expert Mod 8TB
You never read the file.
Jan 6 '12 #3

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

Similar topics

2
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
1
by: Joel Goldstick | last post by:
I wanted to write a simple page to let me choose a directory and then list the files in it. The end goal was to make an easy way to copy all the file names in a directory. I tested with Opera7,...
4
by: Bhavin | last post by:
Hi I'm trying to input image file using this synax. <input type=file name="tx_file" accept="image/*" class=boxText> But when open file dialouge appears, it shows all the file and user can select...
1
by: Axe | last post by:
Here's the problem: I've got an ASP.NET (C#) web page that has a single <input type=file> control on it for uploading a file. The way the code works is that the uploaded file is then parsed for...
4
by: Alessandro | last post by:
Hi everybody, I tried to find some information about my subject with google, but I didn't find anything. I need to read a text file, process the entire content, then kill. In the meantime I...
4
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
116
by: dmoran21 | last post by:
Hi All, I am working on a program to take input from a txt file, do some calculations, and then output the results to another txt file. The program that I've written compiles fine for me, however,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.