Microsoft MVP성태의 닷넷 이야기
안녕하세요.. 파일 생성 처리 문제로 .... [링크 복사], [링크+제목 복사],
조회: 11382
글쓴 사람
생초보 (huss5210 at hanmail.net)
홈페이지
첨부 파일
 

안녕하세요 기초 수준이 초보라... 이상하게 계속 오류가 나거나
저장이 되더라도.. 파일이 구동이 되지 않아서.. 며칠째 같은 코드만 계속 치는거 같아서..
도무지 이해도 안되어서 이렇게.....

파일을 사이즈씩 vector담아서.. 그 데이터를 .... 저장하고 싶습니다.
ㅜㅜ;;;


-----------------------1

#include <stdio.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <vector>

using namespace std;

 
int main(int argc, char *argv[])
{

   std::ifstream in_file;
   std::ofstream out_file;

   vector<unsigned char *> sendI;
   vector<unsigned char *>::iterator sendIt;

  
   
  in_file.open("aa.mp3" , ios::in|ios::binary |ios::ate);
  out_file.open("bb.mp3", ios::out |ios::binary | ios::trunc);
     

     in_file.seekg(0,ios::end);
     int len = in_file.tellg();
     in_file.seekg(0,ios::beg);
  int check = 1024;
  int wilecout = len/check;
  int noreadcout = 0;
  int v_count =0;


      unsigned char *Orig = new unsigned char[check];


  int i=1;
        while ( i <= wilecout )
        {
    in_file.seekg(noreadcout-1,ios::beg);

    in_file.read((char *)Orig,check);
    sendI.push_back(Orig);

    noreadcout = check*i;
       i++;
        }
        
       v_count = len -noreadcout;

  if(v_count > 0)
     {
       in_file.read((char *)Orig,v_count);
    sendI.push_back(Orig);
     }


  out_file.write((const char*) sendI[i],check);
 
    cout << len << endl;
    cout << sendI.size() << endl;
  
 out_file.flush();
 out_file.close();

 in_file.close();
 
 return 0;
}



-----------------------------------------2
#include <stdio.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <vector>

using namespace std;

 
int main(int argc, char *argv[])
{

   std::ifstream in_file;
   std::ofstream out_file;

   vector<unsigned char *> sendI;
   vector<unsigned char *>::iterator sendIt;

  
   
  in_file.open("aa.mp3" , ios::in|ios::binary |ios::ate);
  out_file.open("bb.mp3", ios::out |ios::binary | ios::trunc);
     

     in_file.seekg(0,ios::end);
     int len = in_file.tellg();
     in_file.seekg(0,ios::beg);
     int check = 1024;
     int wilecout = len/check;
     int noreadcout = 0;
     int v_count =0;
 

        int i=1;
        while (    i <= wilecout )
        {
             unsigned char *Orig = new unsigned char[check];

             in_file.seekg(noreadcout,ios::beg);

             in_file.read((char *)Orig,check);
             sendI.push_back(Orig);
   
              //cout << sendI[1] << endl;

             noreadcout = check*i;
         i++;
        }
        
       v_count = len -noreadcout;

        if(v_count > 0)
     {
             unsigned char *Orig1 = new unsigned char[v_count];
 
 
         in_file.read((char *)Orig1,v_count);
             sendI.push_back(Orig1);
     }

       char *ttt = new char[len*2];

        for(sendIt = sendI.begin(); sendIt != sendI.end(); sendIt++)
     {        
             strcat(ttt,(char *)*sendIt);
     }

      out_file.write((const char*)ttt,len);
 
 
    cout << len << endl;
    cout << sendI.size() << endl;
  
    out_file.flush();
    out_file.close();

    in_file.close();
 
 return 0;
}

계속 그자리를 맵도는 것 같아서요..ㅜㅜ;;
혼자 보다가 보니까 이리저리 답을 구하기가 쉽지 않아서 이렇게 .. 글을 올려봅니다.









[최초 등록일: ]
[최종 수정일: 1/26/2010]


비밀번호

댓글 작성자
 



2010-01-26 06시23분
 이런 건 답을 알려드리는 것은 도움이 되지 않습니다. 사실 저도 이젠 나이가 들어서(!) ^^; C/C++ 코드가 눈에도 잘 안들어오고.

혹시, 도구를 사용하시나요? Visual Studio 같은.
가능하면 Visual Studio를 사용하시고요. 그 도구에서 제공하는 디버깅 기능을 사용하십시오. 정지점(Break Point)를 잡고 라인 단위로 코드를 실행하면서 변수의 값들을 하나 하나 추적하다 보면 자신이 원하지 않는 값으로 빠지는 경우를 잡아낼 수 있을 것입니다. (절대, 처음부터 printf 따위로 디버깅하려고 하지 마세요. ^^ - 물론 도움이 되는 경우가 있지만.)

또한, 디버깅이 잘 되는지 확인하기 위해서, 처음에는 텍스트 파일로 10byte 단위로 복사하는 것을 해보세요. mp3는 바이너리라서 복사가 잘 되고 있는지 테스트로 확인하기가 쉽지 않습니다.
 
kevin25
2010-01-26 09시35분
[생초보 ] 답변 감사드립니다.
[guest]

... 46  47  48  49  50  51  52  53  54  55  [56]  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
1238(non...3/13/201411981(글쓴이의 요청으로 삭제합니다.) [2]
1237(non...3/11/201412073(글쓴이의 요청으로 삭제합니다.) [2]
1236(non...3/11/201412962(글쓴이의 요청으로 삭제합니다.) [2]
1235(non...3/10/201412090(글쓴이의 요청으로 삭제합니다.) [2]
1234(non...3/10/201414126(글쓴이의 요청으로 삭제합니다.) [3]
1233(non...3/9/201412235(글쓴이의 요청으로 삭제합니다.) [4]
1232(non...3/8/201411333(글쓴이의 요청으로 삭제합니다.) [2]
1231(non...3/7/201412621(글쓴이의 요청으로 삭제합니다.) [9]
1230POCO3/7/201412971쓰레드 안에서 DependencyProperty get, set시 또 다른 스레드 오류.. [1]
1229(non...3/6/201412721(글쓴이의 요청으로 삭제합니다.) [11]
1228POCO3/6/201411235안녕하세요. 질문이 있습니다. [1]
1226김형진3/4/201419783안녕하세요 windows azure에 관해 질문했던 사람입니다. [2]
1224(non...3/3/201415907(글쓴이의 요청으로 삭제합니다.) [11]
1223sadf...3/3/201411526아래 질문에 답변 감사드립니다. 한가지 더 궁금한점이 있어 질문드립니다. [1]
1222(non...3/2/201412351(글쓴이의 요청으로 삭제합니다.) [4]
1221(non...3/1/201412424(글쓴이의 요청으로 삭제합니다.) [2]
1220Until2/28/201410947질문드립니다. [1]
1219이성환2/28/201410604string.Join()과 Enumerable.Aggregate()의 차이가 궁금합니다. [2]파일 다운로드1
1218김형진2/25/201412052안녕하세요. window azure에 대해서 질문이 있어서 문의 드립니다 [4]
1217(non...2/23/201412533(글쓴이의 요청으로 삭제합니다.) [1]
1215아리수2/20/201416064C# 공부하면서 WPF에 대한 질문. [2]
1214조광훈2/20/201414308IIS8 응용프로그램 풀 관련 질문 드립니다. [2]파일 다운로드1
1213김태훈2/17/201411196가상화 프로그램 질문입니다. [1]파일 다운로드1
1212조광훈2/13/201410352ISAPI 필터에서 커스텀 헤더 정보 추가 [1]파일 다운로드1
1211조광훈2/12/201413781isapi 필터 로드 오류 [2]
1208박지호2/9/201417120[오타] 시작하세요 C# 프로그래밍 p.267 ~ 350 [1]
... 46  47  48  49  50  51  52  53  54  55  [56]  57  58  59  60  ...