Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: how to save a file? Pin
David Crow23-Jan-08 2:44
David Crow23-Jan-08 2:44 
Generalstd::fstream and std::transform about lower case question Pin
Maxwell Chen22-Jan-08 19:16
Maxwell Chen22-Jan-08 19:16 
GeneralProblem is solved. Pin
Maxwell Chen22-Jan-08 19:34
Maxwell Chen22-Jan-08 19:34 
GeneralRe: std::fstream and std::transform about lower case question Pin
Stephen Hewitt22-Jan-08 19:44
Stephen Hewitt22-Jan-08 19:44 
GeneralRe: std::fstream and std::transform about lower case question Pin
Maxwell Chen23-Jan-08 16:09
Maxwell Chen23-Jan-08 16:09 
GeneralRe: std::fstream and std::transform about lower case question Pin
Stephen Hewitt24-Jan-08 11:59
Stephen Hewitt24-Jan-08 11:59 
GeneralRe: std::fstream and std::transform about lower case question Pin
Maxwell Chen24-Jan-08 16:21
Maxwell Chen24-Jan-08 16:21 
GeneralRe: std::fstream and std::transform about lower case question Pin
Stephen Hewitt24-Jan-08 16:36
Stephen Hewitt24-Jan-08 16:36 
Try something like this then:
// VanillaConsole.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <algorithm>
 
int main(int argc, char* argv[])
{
	using namespace std;
 
	// Open the input file.
	ifstream ifs("C:\\Data.txt");
	if (!ifs)
	{
		cerr << "Failed to open data file!" << endl;
		return 1;
	}
 
	// Get iterators for the file.
	istream_iterator<char> isi(ifs);
	istream_iterator<char> isi_end;
 
	// The string to put the contents of the file in (but in lower case).
	string s;
 
	// Copy the file's contents to the string but in lower case.
	transform(isi, isi_end, back_inserter(s), ::tolower);
 
	// Output the results.
	cout << s << endl;
 
	return 0;
}


NOTE: I couldn't test this as MSVC6's std::string class is missing the push_back member function. Section 21.3.5 of the C++ standard says it should exist.

Steve

GeneralRe: std::fstream and std::transform about lower case question Pin
Maxwell Chen24-Jan-08 20:03
Maxwell Chen24-Jan-08 20:03 
QuestionHow to automate a server Pin
CodingLover22-Jan-08 18:53
CodingLover22-Jan-08 18:53 
Generalstd::map, std::for_each and boost::bind Pin
User 58385222-Jan-08 17:17
User 58385222-Jan-08 17:17 
GeneralRe: std::map, std::for_each and boost::bind Pin
Stephen Hewitt22-Jan-08 18:34
Stephen Hewitt22-Jan-08 18:34 
GeneralRe: std::map, std::for_each and boost::bind Pin
User 58385222-Jan-08 18:41
User 58385222-Jan-08 18:41 
GeneralRe: std::map, std::for_each and boost::bind Pin
Stephen Hewitt22-Jan-08 18:49
Stephen Hewitt22-Jan-08 18:49 
Questionproblem with memory allocation when trying to store a large table Pin
gluballs22-Jan-08 16:15
gluballs22-Jan-08 16:15 
GeneralRe: problem with memory allocation when trying to store a large table Pin
User 58385222-Jan-08 17:25
User 58385222-Jan-08 17:25 
GeneralRe: problem with memory allocation when trying to store a large table Pin
gluballs22-Jan-08 18:18
gluballs22-Jan-08 18:18 
GeneralRe: problem with memory allocation when trying to store a large table Pin
User 58385222-Jan-08 18:22
User 58385222-Jan-08 18:22 
GeneralRe: problem with memory allocation when trying to store a large table Pin
gluballs22-Jan-08 18:56
gluballs22-Jan-08 18:56 
GeneralRe: problem with memory allocation when trying to store a large table Pin
User 58385222-Jan-08 18:58
User 58385222-Jan-08 18:58 
GeneralRe: problem with memory allocation when trying to store a large table Pin
Stephen Hewitt22-Jan-08 19:36
Stephen Hewitt22-Jan-08 19:36 
GeneralRe: problem with memory allocation when trying to store a large table Pin
David Crow23-Jan-08 3:27
David Crow23-Jan-08 3:27 
QuestionRead particular bit in a .bin file Pin
Kennis22-Jan-08 16:02
Kennis22-Jan-08 16:02 
GeneralRe: Read particular bit in a .bin file Pin
Don Box22-Jan-08 19:06
Don Box22-Jan-08 19:06 
GeneralPointers and reference Pin
vibindia22-Jan-08 15:08
vibindia22-Jan-08 15:08 

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.