views:

29

answers:

1

What changes are needed when porting "setbuf" in VS2005 to VS2008?

I have to modify a project in VS2005 to VS2008 to be able to build it. Below is the line of code that needs to be compiled in VS2008.

 std::ifstream In; 
 In.setbuf(FileBuffer, BUFFER_REGION_SIZE); 

When I compile the above code in VS2008, I see the below error.

 error C2039: 'setbuf' : is not a member of 'std::basic_ifstream<_Elem,_Traits>' 

What needs to be done to compile it in VS2008?

+1  A: 

Did you try something like In.rdbuf()->pubsetbuf(FileBuffer, BUFFER_REGION_SIZE);?

See http://www.cplusplus.com/reference/iostream/streambuf/pubsetbuf/

Mark B
I have tried your suggestion and it solved my problem.Thanks Mark.
Lakshmi
Can it be used with both ifstream and ofstream objects?
Lakshmi
@Lakshmi Yes it can.
Mark B
Thanksa for the info
Lakshmi