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: asdf | September 5, 2010 @ 5:35pm
C++ Code
[
Download
]
#include <iostream> #include <fstream> #include <string> #include <vector> #include "stdlib.h" using namespace std; void flush_left ( ofstream &out_file, int width, vector <string> v1) { int new_line = 0; int line_size =0; for ( int i =0; i< width+4; i++) { out_file << "-"; } out_file << endl; for ( int i = 0; i < v1.size() ;i++) { if ( new_line == 0) { line_size = line_size + v1[i].size()+1; out_file << "| " << v1[i]; new_line = 1; cout << "1" << v1[i] << endl; } else { if ( line_size + v1[i].size()+1 <= width) { line_size = line_size + v1[i].size()+1; out_file << " " << v1[i]; new_line = 1; cout << "2" << v1[i] << endl; } else { for ( int j = line_size; j < width+4; j++) { out_file << " "; } out_file << "|" << endl; out_file << "| " << v1[i]; line_size = v1[i].size()+1; new_line = 1; cout << "3" << v1[i] << endl; } } } for ( int i=0; i< width-line_size; i++) { out_file << " "; } out_file << "|"; out_file << endl; for ( int i =0; i< width+4; i++) { out_file << "-"; } } 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.49 / 8
47 Votes
http://codebin.yi.org/825
page generated in 0.01 seconds