Click here to Skip to main content
15,892,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Why the controls do not show? Pin
David Crow8-Dec-10 4:14
David Crow8-Dec-10 4:14 
AnswerRe: Why the controls do not show? Pin
yu-jian9-Dec-10 0:52
yu-jian9-Dec-10 0:52 
QuestionHow can identify click on hashbutton or item label in Tree Ctrel? Pin
Le@rner3-Dec-10 23:00
Le@rner3-Dec-10 23:00 
AnswerRe: How can identify click on hashbutton or item label in Tree Ctrel? Pin
User 74293383-Dec-10 23:38
professionalUser 74293383-Dec-10 23:38 
Questionhow to input into array from keyboard Pin
atoivan3-Dec-10 16:20
atoivan3-Dec-10 16:20 
AnswerRe: how to input into array from keyboard Pin
Dr.Walt Fair, PE3-Dec-10 16:36
professionalDr.Walt Fair, PE3-Dec-10 16:36 
AnswerRe: how to input into array from keyboard Pin
Luc Pattyn3-Dec-10 17:20
sitebuilderLuc Pattyn3-Dec-10 17:20 
AnswerRe: how to input into array from keyboard [modified] Pin
Alain Rist3-Dec-10 23:55
Alain Rist3-Dec-10 23:55 
Hi,

In this area there are some Wink | ;) differences between C++ and Java.

To input nb values of type Val from some stream (console, file or string) to a C++ std::array<Val, nb> you can use:
#include <iostream>
#include <array>
using std::tr1::array;

// Input nb elements of type Val from in. 
// Returns input as a std::array<Val, nb> when nb elements are succesfully read, or in.eof().
template <class Val, size_t nb>
array<Val, nb> Input(std::istream& in)
{
	array<Val, nb> vals = {0};
	while (!in.eof()) 
	{
		std::copy_n(std::istream_iterator<Val>(in), vals.size(), vals.begin());
		if (in.good())
			break;
		in.clear();
		in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
 	};
	return vals;
}
int main()
{
	// test with cin
	std::cout << "Input five integers" << std::endl;
	array<int, 5> vals = Input<int, 5>(std::cin);
	std::copy(vals.begin(), vals.end(), std::ostream_iterator<int>(std::cout, "\n"));
	return 0;
}


Good luck Smile | :)
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Saturday, December 4, 2010 6:08 AM

QuestionC++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Cachel3-Dec-10 15:00
Cachel3-Dec-10 15:00 
AnswerRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Dr.Walt Fair, PE3-Dec-10 16:26
professionalDr.Walt Fair, PE3-Dec-10 16:26 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Cachel3-Dec-10 19:34
Cachel3-Dec-10 19:34 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? [modified] Pin
User 74293383-Dec-10 22:24
professionalUser 74293383-Dec-10 22:24 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Maximilien4-Dec-10 7:22
Maximilien4-Dec-10 7:22 
QuestionRead data using assembly Pin
MKC0023-Dec-10 2:39
MKC0023-Dec-10 2:39 
AnswerRe: Read data using assembly Pin
Rajesh R Subramanian3-Dec-10 2:50
professionalRajesh R Subramanian3-Dec-10 2:50 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 3:45
MKC0023-Dec-10 3:45 
GeneralRe: Read data using assembly Pin
Rajesh R Subramanian3-Dec-10 3:53
professionalRajesh R Subramanian3-Dec-10 3:53 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 22:09
MKC0023-Dec-10 22:09 
AnswerRe: Read data using assembly Pin
Aescleal3-Dec-10 6:17
Aescleal3-Dec-10 6:17 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 22:10
MKC0023-Dec-10 22:10 
GeneralRe: Read data using assembly Pin
Emilio Garavaglia4-Dec-10 10:22
Emilio Garavaglia4-Dec-10 10:22 
JokeRe: Read data using assembly Pin
Luc Pattyn4-Dec-10 12:02
sitebuilderLuc Pattyn4-Dec-10 12:02 
QuestionMemory checker and error detector for C++ Pin
Ahmed Charfeddine3-Dec-10 1:38
Ahmed Charfeddine3-Dec-10 1:38 
AnswerRe: Memory checker and error detector for C++ Pin
Maximilien3-Dec-10 4:19
Maximilien3-Dec-10 4:19 
QuestionGet the process ID by the application itself Pin
CodingLover2-Dec-10 23:36
CodingLover2-Dec-10 23:36 

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.