>怎麼一個人也沒有阿</P>[em03]
>這個是對2進制文件的操作</P><
>我用的是一個字符一個字符的操作方法</P>[em04]
>問題解決了</P><
>不用回了</P>[em01]
>不知道你找出的问题在那儿,我判断是alloca和malloc的误用。c++中对指针(内存)的操作总是容易出错,这些系统函数的使用,最好先仔细看看help。</P>
>alloca:</P>4 E, b5 ^/ U7 V3 n( D
>Allocates temporary stack space.</P>
>alloca allocates size bytes on the stack; the allocated space is automatically freed up when the calling function exits.</P># [" T; V& S7 C
>malloc:</P>
>malloc allocates a block of size bytes from the memory heap. It allows a program to allocate memory explicitly as it抯 needed, and in the exact amounts needed.</P>
>Allocates main memory.The heap is used for dynamic allocation of variable-sized blocks of memory. Many data structures, for example, trees and lists, naturally employ heap memory allocation.</P>
>以下是改后的代码</P>
>//---------------------------------------------------------------------------</P>
>#include <vcl.h>8 U# C" c4 \# P3 N- f; C! o
>#include "Unit1.h"
> getcwd(sPath,sizeof(sPath));3 U! b2 l1 ^' D, ?& P- {& G
>free(sPath); free(stream);此两句也有问题。</P>
>char sPath[MAXPATH];不需要释放;</P>! ^- b& Z- j/ j1 w
>fclose(stream)已经起到free(stream)的作用</P>) n3 L9 _3 l8 a
>我已經改成塊處理的方法了</P><
>謝謝你</P>[em01]
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |