행 출력에 관한 질문이요.
가을
#include iostream#include string#include fstream#include cmath#include EMG.h#include vectorusing namespace std;
void tokenize(const string& str, vectorstring& tokens, const string& delimiters = ){ // Skip delimiters at beginning. string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first non-delimiter. string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the not_of lastPos = str.find_first_not_of(delimiters, pos); // Find next non-delimiter pos = str.find_first_of(delimiters, lastPos); }}int main(){ int line_count=0;//파일에 몇줄있는지 카운트 char str[700];//파일에서 한줄을 읽을때 사용 data* p; ifstream in(sup_mvc_01.txt);//파일을 읽기 모드로 while(1) { if(in.getline(str,256)==NULL)//한줄씩 읽습니다. 읽을깨 없다면 루프 종료 break; line_count++;//몇줄인지 카운트 함 } in.clear(); in.seekg(0L,ios::beg); //파일 포인터를 맨앞으로 이동
p=new data[line_count-4]; string s; vectorstring tokens; for(int i=0; iline_count; i++) { in.getline(p[i].temp, 256); if(i3) { p[i].k[0] = p[i].temp; tokenize(p[i].k[0] , tokens, \t); for(int j = 0; j tokens.size(); j++) { p[i].k[j] = tokens[j]; if(j = 2 ) { coutp[i].k[j] ; } } coutendl; tokens.clear(); if(i%10 == 0 && i=10) { getchar(); } } } delete p;}
여기서 일부행만을 출력하려구 하는데 어떻해 하면 될까요?