Difference: CodeFiles (2 vs. 3)

Revision 32015-12-01 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Files

Line: 375 to 379
  %ENDCODE%
Added:
>
>

File Example reverse lines

 
Changed:
<
<
>
>
%CODE{"c++"}%
 
Added:
>
>
#include #include #include #include
 
Added:
>
>
int main( ) { using namespace std; ifstream in_stream; ofstream out_stream;
 
Added:
>
>
in_stream.open("infile.dat"); if (in_stream.fail( )) { cout << "Input file opening failed.\n"; exit(1); }

out_stream.open("outfile.dat"); if (out_stream.fail( )) { cout << "Output file opening failed.\n"; exit(1); }

vector strings; string s; getline(in_stream,s); while (in_stream.eof()) { strings.push_back(s); getline(in_stream,s); }

for (int k = strings.size()-1 ; k >= 0 ; k-- ) { out_stream << strings.at(k) << endl; }

in_stream.close( ); out_stream.close( );

return 0; } %ENDCODE%

 
META FILEATTACHMENT attachment="infile.dat" attr="" comment="" date="1447330367" name="infile.dat" path="infile.dat" size="12" user="JimSkon" version="1"
META FILEATTACHMENT attachment="numbers.dat" attr="" comment="" date="1447330391" name="numbers.dat" path="numbers.dat" size="12" user="JimSkon" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback