#include <ctime> #include<iomanip> #include <iostream> #include<string> using namespace std; void read_network(vector <vector<int> > &VCMA_network){ //read network from input files char *file; ifstream fin; string path,name; path="/global/scratch/jiansen6/network-input/"; name=path+"stubs.dat1"; cout <<"input file name "<<name<<endl; file=new char[name.size()+1]; strcpy (file, name.c_str()); fin.open(file); if (fin.is_open()){ string line; while ( getline(fin, line) ) { istringstream ss(line); vector < int > data; int value; // for data separate by space while (ss >> value) { data.push_back(value); } // for data separate by comma /* char output[30]; while ( ss.getline(output, sizeof(output),',') ){ value = atoi(output); //convert char to int data.push_back(value);} */ VCMA_network.push_back(data); }//end of while } //end of fin.is_open else{ cout<<"Problem with opening the file "<<name<<endl; exit(1); } fin.close(); }
Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- How to blend adsense inside your post?
- PHP: add a download as pdf file button in report page
- Formatting my post
- PHPWind-- A PHP forum script applcaition in China
- Notepad++ - Add C++ compiler
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Renew SSL certificate from StartSSL
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
Friday, July 2, 2010
read in file to vector arrary --C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment