#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
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- Install PHPMailer 5.2.4 and use smtp gmail
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Linux, automatically backup MySQL database daily
- SPSS job interview questions
- Install PHP ibm_db2 extension in Linux (redHat)
Friday, July 2, 2010
read in file to vector arrary --C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment