[ create a new paste ] login | about

Link: http://codepad.org/f7qhHvvX    [ raw code | output | fork ]

sehe - C++, pasted on Feb 12:
#include <string>
#include <iostream>
#include <fstream>
#include <iterator>
#include <algorithm>

void somefunction(const std::string& s)
{
    // call some code here :)
    int length = s.length();
    std::cout << length << "\t" << s << "\n";
}

int main()
{
    std::ifstream test("t.cpp");

    std::for_each(std::istream_iterator<std::string>(test),
                  (std::istream_iterator<std::string>()),
                  somefunction);

    test.close();
}


Output:
8	#include
11	"prelude.h"
8	#include
8	<string>
8	#include
10	<iostream>
8	#include
9	<fstream>
8	#include
10	<iterator>
8	#include
11	<algorithm>
4	void
18	somefunction(const
12	std::string&
2	s)
1	{
2	//
4	call
4	some
4	code
4	here
2	:)
3	int
6	length
1	=
11	s.length();
9	std::cout
2	<<
6	length
2	<<
4	"\t"
2	<<
1	s
2	<<
5	"\n";
1	}
3	int
6	main()
1	{
13	std::ifstream
14	test("t.cpp");
55	std::for_each(std::istream_iterator<std::string>(test),
39	(std::istream_iterator<std::string>()),
14	somefunction);
13	test.close();
1	}


Create a new paste based on this one


Comments: