目前我有一個CSV格式的資料,我要一次一行讀取資料,但是我每一行的資料都可達數十萬,不知道是不是寫法的問題還是C語言本身的限制,字元陣列長度設定到50萬時,一旦執行後,編譯器就會出現堆疊溢出的錯誤,然後強制跳開,這是否是陣列寬度的上限?
不過我是使用VC EXE去呼叫VC DLL檔,該字元陣列是在DLL檔內處理的.
#include "OutBinMap.h"
#include <stdio.h>
#include <windows.h>
#define Max_Size 400000 //設到50萬會當機
#define Max_Size1 20000
const char *delim1=",";
const char *delim2="|";
char* delN(char*);
int spritcount(char*,const char*);
int strSprit(char*,char**,const char*,int);
int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, PVOID pvReserved)
{
return TRUE;
}
EXPORT int OutBinMap(char *FileName,char *TargetFile1,char *TargetFile2)
{
FILE *stream1,*stream2,*stream3;
char Temp[Max_Size]={0},CodeString[Max_Size]={0};
char *part[Max_Size1]={0},*part1[3]={0};
int ii=0,len=0,Title=0,Paragraph=0;
stream1=fopen(FileName,"r");
stream2=fopen(TargetFile1,"a+");
stream3=fopen(TargetFile2,"a+");
while(fgets(Temp, Max_Size, stream1)!=NULL)
{
ii++;
if (ii==3)
{
strcpy(CodeString,delN(Temp));
len=strlen(CodeString);
Title = spritcount(CodeString, delim1);
strSprit(CodeString, part, delim1, Title);
Paragraph = spritcount(part[1], delim2);
strSprit(part[1], part1, delim2, Paragraph);
}
else if (ii==4)
{
}
memset(Temp,0,sizeof(Temp));
memset(CodeString,0,sizeof(CodeString));
}
fclose(stream3);
fclose(stream2);
fclose(stream1);
return 1;
}
.....
目前程式尚在編寫中還未完成....
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.