배열 변수가 변할 수 있나요???

antz의 이미지

아래코드에서...

이부분이 유독 문제를 일으키네요.

	    /* Index data file */
	    memset(pSrcIdx1, 0x00, SIZEBUFFER1K);
	    sprintf(pSrcIdx1, "%s/%02d", pPath, i);

처음부터 에러가 나는것도 아니고,
i가 33일때 ".../data/engine/data/index/idxPersonTelno/33"
식으로 변해 버립니다. 점(.)이 세개로 늘어났습니다.

소스가 일부분이어서 좀 지저분하지만,
pPath라는 변수가 "../data/engine/data/index"를 가지고 있습니다.
헌데 이게 ".../data/engine/data/index"로 변해버립니다.

가끔 이해 할 수없는 에러가 나는군요.
제 잘못일 수도 있는데. 좀 불안하군요.
경험 많으신 분들의 조언 부탁드립니다.

    ...
    #define UNIONPATH "%s/%s"
    #define INDEXPATH   "../data/engine/data/index"
    ...
    int main(void)
    {
        ...
        IndexSave("idxPersonTelno", 100);
        ...
    }

    int IndexSave(LPCSTR pIdxName, int nCount)
    { 
     ... 생략 ...
    sprintf(pPath, UNIONPATH, INDEXPATH, pIdxName);
#ifdef debug
    printf("pPath: %s\n", pSrcIdx1);
#endif

    for(i = 0 ; i < nCount ; i++)
    {
	memset(nPosIndex, 0x00, sizeof(long) * 256);
	if(nCount > 100)
	{
	    /* Index temp file */
	    memset(pTmpIdx, 0x00, SIZEBUFFER1K);
	    sprintf(pTmpIdx,  "%s/%03d.tmp", pPath, i);
	    /* Index data file */
	    memset(pSrcIdx1, 0x00, SIZEBUFFER1K);
	    sprintf(pSrcIdx1, "%s/%03d", pPath, i);
	    /* Index header file */
	    memset(pSrcIdx2, 0x00, SIZEBUFFER1K);
	    sprintf(pSrcIdx2, "%s/%03d.idx", pPath, i);
	}
	else
	{
	    /* Index temp file */
	    memset(pTmpIdx, 0x00, SIZEBUFFER1K);
	    sprintf(pTmpIdx,  "%s/%02d.tmp", pPath, i);
	    /* Index data file */
	    memset(pSrcIdx1, 0x00, SIZEBUFFER1K);
	    sprintf(pSrcIdx1, "%s/%02d", pPath, i);
	    /* Index header file */
	    memset(pSrcIdx2, 0x00, SIZEBUFFER1K);
	    sprintf(pSrcIdx2, "%s/%02d.idx", pPath, i);
#ifdef debug
	    printf("pSrcIdx1 = %s\n", pSrcIdx1);
#endif
	}
    ... 생략 ...

    }

다음은 패스를 open하려다 strerror(errno)을 로그로 남긴 겁니다.

Quote:
[13:28:15] *****************************
[13:28:15] ******* Start Process *******
[13:28:15] *****************************
[13:28:15] Only Person Reinding - Start
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/33] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/34] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/35] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/36] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/37] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/38] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/39] - No such file or directory
[14:34:55] ERROR : [.../data/engine/data/index/idxPersonTelno/40] - No such file or directory

... 생략 ...

[14:38:55] ERROR : [.../data/engine/data/index/idxPersonTelno/96] - No such file or directory
[14:38:55] ERROR : [.../data/engine/data/index/idxPersonTelno/97] - No such file or directory
[14:38:55] ERROR : [.../data/engine/data/index/idxPersonTelno/98] - No such file or directory
[14:38:55] ERROR : [.../data/engine/data/index/idxPersonTelno/99] - No such file or directory
[14:38:59] Only Person Reinding - End
[14:38:59] *****************************
[14:38:59] ******* End Process *******
[14:38:59] *****************************


[/code]
byung82의 이미지

상대 경로일경우 실행 장소에 따라서 디렉토리가 변경될수 있습니다.

정확한것은

getcwd를 사용해서 현재 경로를 확인하시고 생각하시는 경로와 틀린지 맞는지 부터 확인하신후에

만약 생각하신 디렉토리가 틀리시다면 chdir로 생각하신곳으로 이동 시켜주시기 바랍니다.

그럼

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.