<p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">프로젝트 하는데 막히는 부분이 있어서 혹시나 질문 올려봅니다. ㅠ</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">#include<iostream></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">#include<fstream></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">#include<string></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">using namespace std;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">#define max 100</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">char inputline[max];</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">class result{</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">private:</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>char term[10];</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">public:</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>void result_show(char*);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result();</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result(char*);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">};</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">void result::result_show(char *term)</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">{</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(term="0"){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>ifstream inFile("result.txt");</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>while(!inFile.eof()){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inFile.getline(inputline, max);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<inputline<<endl;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inFile.close();</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>else{</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>ifstream inFile("result.txt");</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>while(!inFile.eof()){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inFile.getline(inputline, max);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(!strncmp(inputline, term, 12)){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<inputline<<endl;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>inFile.close();</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">result::result(){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>strcpy(term, "0");</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result_show(term);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">result::result(char* in){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>strcpy(term,in);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<term;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result_show(term);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">int main(){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int sel=0;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>char s_term[10];</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"1. 전체성적보기"<<endl;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"2. 학기별성적보기"<<endl;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>sel;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>switch(sel){</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>case 1:</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result();</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>break;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>case 2:</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cout<<"원하는 학기를 입력하세요. ex)201202"<<endl;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>cin>>s_term;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>result(s_term);</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>break;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">}</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">텍스트 파일의 내용</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201201 웹 프로그래밍<span class="Apple-tab-span" style="white-space: pre;"> </span>23<span class="Apple-tab-span" style="white-space: pre;"> </span>3학점<span class="Apple-tab-span" style="white-space: pre;"> </span>A+</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201201 객체지향<span class="Apple-tab-span" style="white-space: pre;"> </span>32<span class="Apple-tab-span" style="white-space: pre;"> </span>2학점<span class="Apple-tab-span" style="white-space: pre;"> </span>B</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201201 음악의 이해 <span class="Apple-tab-span" style="white-space: pre;"> </span>22<span class="Apple-tab-span" style="white-space: pre;"> </span>3학점<span class="Apple-tab-span" style="white-space: pre;"> </span>B+</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">--------------------------------------------</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201201 <span class="Apple-tab-span" style="white-space: pre;"> </span>8학점<span class="Apple-tab-span" style="white-space: pre;"> </span>3.75</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201202 산과 인생<span class="Apple-tab-span" style="white-space: pre;"> </span>12<span class="Apple-tab-span" style="white-space: pre;"> </span>2학점<span class="Apple-tab-span" style="white-space: pre;"> </span>A</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201202 알고리즘<span class="Apple-tab-span" style="white-space: pre;"> </span>11<span class="Apple-tab-span" style="white-space: pre;"> </span>3학점<span class="Apple-tab-span" style="white-space: pre;"> </span>B</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201202 자바<span class="Apple-tab-span" style="white-space: pre;"> </span>44<span class="Apple-tab-span" style="white-space: pre;"> </span>3학점<span class="Apple-tab-span" style="white-space: pre;"> </span>C+</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">--------------------------------------------</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">201202<span class="Apple-tab-span" style="white-space: pre;"> </span>8학점<span class="Apple-tab-span" style="white-space: pre;"> </span>3.00</p><div style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></div><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><div style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></div><div style="font-family: Gulim; font-size: 12px; line-height: 21px;"><br></div><p style="font-family: Gulim; font-size: 12px; line-height: 21px;"></p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">전체출력과 원하는 학기만 출력 할수 있게 하려는데</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">전체학기는 출력이 되는데 이것도 제대로 한건지 모르겠고</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">원하는 학기만 출력이 안되네요</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">strncmp를 이용해 각 라인앞부분을 비교해서 동일할 경우만 출력하려는데...</p><p style="font-family: Gulim; font-size: 12px; line-height: 21px;">어디가 문제일까요?ㅠ?</p></p>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.