The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: Jaemyeong Eo | September 4, 2010 @ 4:50pm
C++ Code
[
Download
]
#include <iostream> #include <fstream> #include <string> #include <vector> #include "stdlib.h" using namespace std; void flush_left ( ofstream out_file, int num, vector <string> vec_words) { for ( int i=0; i<num; i++) { out_file << "-" << endl; } for ( int i=0 ;i < vec_words.size(); i++) { int line_counter = 0; if ( line_counter == 0 ) { out_file << "| "; } else { if ( line_counter + vec_words[i].size() <= num ) { line_counter = line_counter + vec_words[i].size(); out_file << vec_words[i] << " "; } else { for ( int i = line_counter; i< num; i++)//or num-1. { out_file << " "; } out_file << "|" << endl; } } } } void flush_right ( ifstream file, int num ) { } void full_justify ( ifstream file, int num ) { } int main( int argc, char* argv[]) { ifstream file(argv[1]); if ( !file ) { cerr << "Can't open " << argv[1] << " to read. \n"; return 1; } string words; vector <string> vec_words; while ( file >> words ) { vec_words.push_back(words); } ofstream out_file( argv[2]); if ( !out_file) { cerr << " Can't open " << argv[2] << " to write.\n"; return 1; } int number = atoi(argv[3]); string name = argv[4]; if ( name == "flush_left" ) flush_left ( out_file, number, vec_words ); }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.64 / 8
42 Votes
http://codebin.yi.org/824
page generated in 0.00 seconds