Question about VC++ 7?

Started by
13 comments, last by DevLiquidKnight 20 years, 3 months ago
The fstream.h file doesnt seem to work ? what is the alternative or is there an alternative the ofstream and ifstream data types in the new version of C++ because i cant seem to get my program i made in VC++ 6 to compile because of it
Advertisement
<fstream>

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
I just tried #include <fstream>

Im using MFC too so it is one of my older projects when I didnt use pure Win32.

It still has errors with my ifstream and ofstream data types..
I have a few other errors with my project as well i havent metioned.. such as

WriteHuge for CFile is not a member?


XListCtrl.cpp(40) : error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CXListCtrl::* )(NMHDR *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)'        None of the functions with this name in scope match the target type 

This is giving me problems at:
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick)


and
TrayDialog.cpp(47) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTrayDialog::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'        None of the functions with this name in scope match the target type 

at:
ON_MESSAGE(WM_TRAY_ICON_NOTIFY_MESSAGE,OnTrayNotify)


however the majority of the problems subside in the ofstream and ifstream routines?

coder requires 0xf00d before continue().

Killer Eagle Software

[edited by - DevLiquidKnight on January 4, 2004 6:11:28 PM]
You have to use the "using namespace std" or equivilant.
could someone show an example of using ifstream and ofstream in vc++ 7 just somthing small? I tried typing in using namespace std; in the header no luck?
ok after putting the using namespace std;
in the stdafx header.. it kinda works but now it says using
ifstream in;
in.get(ch) no work?
nor does
filebuf::sh_read
and
ios::nocreate

[edited by - DevLiquidKnight on January 4, 2004 6:19:48 PM]

[edited by - DevLiquidKnight on January 4, 2004 6:20:51 PM]
Can you post some code? and the exact error?
well for some code here... sorry if its not my best work .. its rather old but I wanted to convert it to work with VC++ 7 so
errors in ifstream with get i have this:

EncryptFile(CString lpFileName, CString lpOutFile){	char ch, szData[MAX_STRING_SIZE];	int n = 0, dat = 0;         ifstream in;         ofstream out;	CString data;	CFile file;	// open for input	in.open(lpFileName);	while(in.get(ch) && !(in.eof()))	{		szData[n] = ch;		n++;	}	in.close();	// close input		data = szData;	data.ReleaseBuffer(n+1);	int v = n-1;	n = 0;	/*	seq[k] = Rand[k]%256<br><br>	Ciphering:<br>	if(k % 2 == 0)<br>	  cipher[k] = text[k]^seq[k]<br>	else<br>	  seq[k] = seq[k] + key<br>	  cipher[k] = text[k]^seq[k]<br><br>	Deciphering:<br>	if(k % 2 == 0)<br>	  text[k] = cipher[k]^seq[k]<br>	else <br>	  seq[k] = seq[k] - key<br>	  text[k] = cipher[k]^seq[k]<br>	*/</font><br>	<font color=gray>// open output<br></font><br>	out.open(lpOutFile);<br>	<font color=blue>while</font>(n != data.GetLength()-1)<br>	{<br>		<font color=blue>if</font>(n % 2 == 0)<br>		{<br>			dat = (<font color=blue>int</font>)szData[<font color=purple>n</font>] ^ chbuf[<font color=purple>v</font>];<br>		}<br>		<font color=blue>else</font><br>		{<br>			dat = (<font color=blue>int</font>)szData[<font color=purple>n</font>] ^ chbuf[<font color=purple>v</font>] ^ key[<font color=purple>n</font>];<br>		}<br>		out &lt;&lt; (<font color=blue>char</font>)dat;<br>		v–;<br>		n++;<br>	}<br>	out.close();<br>	<font color=gray>// close output<br></font><br>	<font color=gray>// do second encryption<br></font><br>	<font color=blue>return</font> <font color=blue>true</font>;<br>}<br></pre><!–ENDSCRIPT–><br>Error:<br><pre><br>error C2039: 'get' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'<br>        with<br>        [<br>            _Elem=char,<br>            _Traits=std::char_traits<char><br>        ]<br> </pre> <br><br><br><br>filebuf::sh_read<br>and<br>ios::nocreate  <br>the code is:<br>   <!–STARTSCRIPT–><pre class="source"><br>DWORD CCrc32Dynamic::FileCrc32Streams(LPCTSTR szFilename, DWORD &dwCrc32) const<br>{<br>#<font color=blue>if</font> UNICODE || _UNICODE<br>	<font color=blue>return</font> ERROR_NOT_SUPPORTED;<br><font color=green>#<font color=blue>else</font></font><br>	_ASSERTE(szFilename);<br>	_ASSERTE(lstrlen(szFilename));<br><br>	DWORD dwErrorCode = NO_ERROR;<br>	ifstream file;<br><br>	dwCrc32 = 0xFFFFFFFF;<br><br>	<font color=blue>try</font><br>	{<br>		<font color=gray>// Is the table initialized?<br></font><br>		<font color=blue>if</font>(m_pdwCrc32Table == NULL)<br>			<font color=blue>throw</font> 0;<br><br>		<font color=gray>// Open the file<br></font><br>		file.open(szFilename, ios::in | ios::nocreate | ios::binary, filebuf::sh_read);<br>		<font color=blue>if</font>(!file.is_open())<br>			dwErrorCode = file.fail();<br>		<font color=blue>else</font><br>		{<br>			<font color=blue>char</font> buffer[<font color=purple>MAX_BUFFER_SIZE</font>];<br>			<font color=blue>int</font> nLoop, nCount;<br>			nCount = file.read(buffer, <font color=blue>sizeof</font>(buffer)).gcount();<br>			<font color=blue>while</font>(nCount)<br>			{<br>				<font color=blue>for</font>(nLoop = 0; nLoop &lt; nCount; nLoop++)<br>					CalcCrc32(buffer[<font color=purple>nLoop</font>], dwCrc32);<br>				nCount = file.read(buffer, <font color=blue>sizeof</font>(buffer)).gcount();<br>			}<br><br>			file.close();<br>		}<br>	}<br>	<font color=blue>catch</font>(…)<br>	{<br>		<font color=gray>// An unknown exception happened, or the table isn't initialized<br></font><br>		dwErrorCode = ERROR_CRC;<br>	}<br><br>	<font color=blue>if</font>(file.is_open()) file.close();<br><br>	dwCrc32 = ~dwCrc32;<br><br>	<font color=blue>return</font> dwErrorCode;<br><font color=green>#endif</font><br>}<br></pre><!–ENDSCRIPT–>    <br>and for the error for that i get<br><pre><br>error C2039: 'nocreate' : is not a member of 'std::basic_ios<_Elem,_Traits>'<br>        with<br>        [<br>            _Elem=char,<br>            _Traits=std::char_traits<char><br>        ]<br><br>error C2065: 'nocreate' : undeclared identifier<br>error C2676: binary '|' : 'const std::_Iosb<_Dummy>::_Openmode' does not define this operator or a conversion to a type acceptable to the predefined operator<br>        with<br>        [<br>            _Dummy=int<br>        ]<br>error C2039: 'sh_read' : is not a member of 'std::basic_filebuf<_Elem,_Traits>'<br>        with<br>        [<br>            _Elem=char,<br>            _Traits=std::char_traits<char><br>        ]<br>error C2065: 'sh_read' : undeclared identifier<br><br> </pre> <br>coder requires 0xf00d before continue().<br><br><a href = "http://www.geocities.com/killereaglesoftware">Killer Eagle Software</a>   <br><br><SPAN CLASS=editedby>[edited by - DevLiquidKnight on January 4, 2004 6:28:45 PM]</SPAN>
What is the compiler error?
there sorry i had to edit post to put it in

This topic is closed to new replies.

Advertisement