Click here to Skip to main content
16,006,442 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: read from file Pin
Nish Nishant27-Jan-02 17:49
sitebuilderNish Nishant27-Jan-02 17:49 
GeneralRe: read from file Pin
Christian Graus27-Jan-02 17:58
protectorChristian Graus27-Jan-02 17:58 
GeneralRe: read from file Pin
Christian Graus27-Jan-02 18:05
protectorChristian Graus27-Jan-02 18:05 
GeneralRe: read from file Pin
Nish Nishant27-Jan-02 18:21
sitebuilderNish Nishant27-Jan-02 18:21 
GeneralRe: read from file Pin
Christian Graus27-Jan-02 19:26
protectorChristian Graus27-Jan-02 19:26 
GeneralRe: read from file Pin
Nish Nishant27-Jan-02 19:37
sitebuilderNish Nishant27-Jan-02 19:37 
GeneralRe: read from file Pin
Christian Graus27-Jan-02 20:12
protectorChristian Graus27-Jan-02 20:12 
GeneralRe: read from file Pin
Christian Graus27-Jan-02 16:54
protectorChristian Graus27-Jan-02 16:54 
First of all, please only ask the one question once.

Secondly, the following code should work, assuming the numbers are properly delimited. It currently reads in strings, but you can use atoi, or convert it to read int's, I am sure.

This program is my playground for using IOStreams, so I sure there are #include and using std:: statements in there that are not needed.

<pre>
#include "stdafx.h"
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <sstream>

using std::copy;
using std::vector;
using std::string;
using std::ifstream;
using std::ostream_iterator;
using std::cout;
using std::back_inserter;
using std::getline;

using std::ostringstream;
using std::istream_iterator;

int main(int argc, char* argv[])
{
string currentLine;

ifstream str("c:\\winzip.log");
if (!str.is_open())
{
cout << "It's stuffed\n";
return -1;
}

vector<string> file_contents;

copy(istream_iterator<string>(str),istream_iterator<string>(), back_inserter(file_contents));

// Now print out the results
copy(file_contents.begin(), file_contents.end(), ostream_iterator<string>(cout, "\n"));

return 0;
}
</pre>


Christian

I have come to clean zee pooollll. - Michael Martin Dec 30, 2001

Picture the daffodil. And while you do that, I'll be over here going through your stuff.

Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
GeneralRe: read from file Pin
Jamie Hale28-Jan-02 5:05
Jamie Hale28-Jan-02 5:05 
GeneralRe: read from file Pin
Christian Graus28-Jan-02 8:44
protectorChristian Graus28-Jan-02 8:44 
GeneralInstalling a callback between two applications Pin
Mr.Freeze27-Jan-02 15:52
Mr.Freeze27-Jan-02 15:52 
GeneralRe: Installing a callback between two applications Pin
27-Jan-02 16:09
suss27-Jan-02 16:09 
GeneralRe: Installing a callback between two applications Pin
Mr.Freeze27-Jan-02 17:47
Mr.Freeze27-Jan-02 17:47 
GeneralRe: Installing a callback between two applications Pin
27-Jan-02 18:39
suss27-Jan-02 18:39 
Generalread from file Pin
marouane miftah el kheir27-Jan-02 15:27
marouane miftah el kheir27-Jan-02 15:27 
GeneralRandom Numbers :: C++ Pin
valikac27-Jan-02 15:00
valikac27-Jan-02 15:00 
GeneralRe: Random Numbers :: C++ Pin
Michael Dunn27-Jan-02 17:22
sitebuilderMichael Dunn27-Jan-02 17:22 
GeneralRe: Random Numbers :: C++ Pin
markkuk27-Jan-02 19:44
markkuk27-Jan-02 19:44 
GeneralRe: Random Numbers :: C++ Pin
valikac28-Jan-02 4:37
valikac28-Jan-02 4:37 
GeneralHelp with Win32, but its in the VB forum Pin
David Wengier27-Jan-02 14:53
David Wengier27-Jan-02 14:53 
Generalplease help me this is urgent Pin
borland27-Jan-02 14:50
borland27-Jan-02 14:50 
GeneralRe: please help me this is urgent Pin
27-Jan-02 15:13
suss27-Jan-02 15:13 
GeneralRe: please help me this is urgent Pin
Michael Dunn27-Jan-02 17:19
sitebuilderMichael Dunn27-Jan-02 17:19 
Questioninput reading? Pin
marouane miftah el kheir27-Jan-02 13:00
marouane miftah el kheir27-Jan-02 13:00 
AnswerRe: input reading? Pin
borland27-Jan-02 14:52
borland27-Jan-02 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.