|
AnsiString은 이미 검증된 절대 최강의 문자열 클래스입니다.
그러므로 AnsiString 버그일 가능성은 전혀 없고요.
newpath 사용이 잘못되어 있군요.
char *newpath;
--> char newpath[256];
newpath = "";
--> newpath[0] = 0;
char *newpath2;
--> char newpath2[256];
newpath2 = "";
--> newpath2[0] = 0;
이렇게 바꾸세요.
만두박사 님이 쓰신 글 :
: 그 이전 줄에서 이미 문제가 생기네요.
:
: temp_foldername_2 = "experiment_0" + IntToStr(pop_num);
:
: 문장에 의하여
:
: temp_foldername_2 = experiment_011
:
: 이 되야 하는데,
:
: temp_foldername_2 가 자꾸 g11 이라는 희한한 문장으로 변하게 됩니다. 그리고 지적해주신 부분에서는,
:
: foldername = temp_foldername_2.c_str()
:
: 으로 설정하였기 때문에, 그 부분은 문제가 발생하지 않는 것 같습니다.
:
: p.s: 조금 더 조사해보니, 11번째 줄
: : : strcat(newpath, foldername);
: 이 사용된 후부터 AnsiString과 char 들이 이상해졌습니다.
:
: 이유가 대체 뭘까요...
: -------------------------------------------
:
: aa 님이 쓰신 글 :
: : char * 형식이랑 AnsiString 형식이 안맞아서그런거같은데요
: : tempfoldername_2 는 AnsiString 이고
: : foldername 은 char * 형이니;
: :
: : 만두박사 님이 쓰신 글 :
: : : AnsiString이 꼬여서 원하는 문자가 제대로 입력되지 않고 있습니다.
: : :
: : : else if(pop_num < 100)
: : : temp_foldername_2 = "experiment_0" + IntToStr(pop_num);
: : :
: : : 줄을 지나면 temp_foldername_2 가 "experiment_011"이 되어야 하는데,
: : : 자꾸 "istory matching" 이런 식으로 이상한 문자들이 들어가게 되네요.
: : :
: : : 무엇이 문제인지 알고 싶습니다.
: : :
: : :
: : :
: : : int CreateFiles(char *foldername)
: : : {
: : : int i;
: : :
: : : int popsize;
: : : popsize = 12;
: : : int pop_num;
: : : pop_num = 11;
: : :
: : : char *newpath;
: : : char *newfile;
: : :
: : : char *newpath2;
: : : char *foldername_2;
: : :
: : : newpath = "";
: : : strcat(newpath, foldername);
: : :
: : : // 새폴더 생성
: : : mkdir(newpath);
: : :
: : : for(i=0;i<popsize;i++)
: : : {
: : : // 새하위폴더명 생성
: : : if(pop_num < 10)
: : : temp_foldername_2 = "experiment_00" + IntToStr(pop_num);
: : : else if(pop_num < 100)
: : : temp_foldername_2 = "experiment_0" + IntToStr(pop_num);
: : : else if(pop_num < 1000)
: : : temp_foldername_2 = "experiment_" + IntToStr(pop_num);
: : : else
: : : {
: : : // Error!!
: : : // ShowMessage "Too many population!"
: : : }
: : :
: : : foldername_2 = "";
: : : foldername_2 = temp_foldername_2.c_str();
: : :
: : : // 새하위폴더 생성
: : : newpath2 = "";
: : : strcpy(newpath2, newpath);
: : : strcat(newpath2, "\\");
: : : strcat(newpath2, foldername_2);
: : : mkdir(newpath2);
: : :
: : : // 새파일명 생성
: : : newfile = "DATAFILE";
: : : strcat(newpath2, newfile);
: : :
: : : // 새파일 생성
: : : ofstream outfile1;
: : : outfile1.open(newfile);
: : : outfile1<<"MBH"<<" "<<"!!"<<endl;
: : : outfile1.close();
: : : }
: : : return 0;
: : : }
|