Prabhu K.M

Dear Members,

Am new to this group.I had one doubt in vc++ buffering concept

My input code to read and write a text file is

Wchar InputText[99999]=L" ";

Wchar OutputText[99999]=L" ";

Wchar Buffer[99999]= " ";

I want to give a maximum buffer size value and my file size is around 5 mb

Is it possible to do so, if yes how

Please reply me to this question

with regards,

Prabhu K.m



Re: Visual C++ Language Buffer Size

Sdi

Don't try to allocate huge buffers on the stack; find out how large the file is and then allocate a buffer on the heap. But: do you really need to read an entire multi-megabyte file into memory at one time Is there any reason you can't use a file mapping



Re: Visual C++ Language Buffer Size

einaros

You should probably spend some time reading about memory management in C++. There are plenty of resources at www.codeproject.com and www.codeguru.com, and a whole lot more available thorugh your favorite search engine. You should also read up on the differences between the stack and heap (see e.g. http://www.codersource.net/c++_dynamic_memory_allocation.aspx).




Re: Visual C++ Language Buffer Size

Marius Bancila

Code Snippet

Wchar InputText[99999]=L" ";

Wchar OutputText[99999]=L" ";

Wchar Buffer[99999]= " ";

should rather be

Code Snippet

Wchar InputText[99999]= {0};

Wchar OutputText[99999]= {0};

Wchar Buffer[99999]= {0};

As for the rest, why don't you read the file in a loop using a buffer of, say, 4kb Or if it's absolutelly necessary to read it all in a chunk, open the file, find the length and then allocate the necessary memory on the heap.






Re: Visual C++ Language Buffer Size

Prabhu K.M

Thanks for ur timely reply

yes i want to read the entire file into one time.here i am doing the unicode conversion, unicode text to Ascii text in same language.

how to intialize the buffer in heap. is there any limitaion for giving the buffer size or input text size

with regards,

Prabhu





Re: Visual C++ Language Buffer Size

Prabhu K.M

Thanks for ur timely reply

Here am doing the unicode conversion from one unicode language file to ascii file in the same language.

how to clear the buffer while executing the file

if i give the above code as replacement then it shows syntax error

please give me a reply how to assign a buffer and input text and output text to maximum size

with regards,

Prabhu k.m