>怎麼一個人也沒有阿</P>[em03]
>這個是對2進制文件的操作</P><
>我用的是一個字符一個字符的操作方法</P>[em04]
>問題解決了</P><
>不用回了</P>[em01]
>不知道你找出的问题在那儿,我判断是alloca和malloc的误用。c++中对指针(内存)的操作总是容易出错,这些系统函数的使用,最好先仔细看看help。</P>
>alloca:</P>
>Allocates temporary stack space.</P>" v3 W2 q* r: n! G' F
>alloca allocates size bytes on the stack; the allocated space is automatically freed up when the calling function exits.</P>
>malloc:</P>. N! R& u. F2 q, v, z2 x+ x" i/ X" R
>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>6 J/ @, b9 W+ h: A% D1 l* ~' M" k
>以下是改后的代码</P>! A! a/ W$ L0 u. Z' k
>//---------------------------------------------------------------------------</P>' t7 h" J5 W9 H' F& S- ~2 j2 @8 J) A
>#include <vcl.h>" A1 f$ [# E& U4 C0 P
>#include "Unit1.h"
> getcwd(sPath,sizeof(sPath));
>free(sPath); free(stream);此两句也有问题。</P>
>char sPath[MAXPATH];不需要释放;</P>
>fclose(stream)已经起到free(stream)的作用</P>0 F. U/ y, ]0 y# n4 n, ~! n
>我已經改成塊處理的方法了</P><
>謝謝你</P>[em01]
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |