Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Question about VC++ 7?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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][i] = Rand[i][k]%256

Ciphering:
if(k % 2 == 0)
cipher[k] = text[k]^seq[k]
else
seq[k] = seq[k] + key
cipher[k] = text[k]^seq[k]

Deciphering:
if(k % 2 == 0)
text[k] = cipher[k]^seq[k]
else
seq[k] = seq[k] - key
text[k] = cipher[k]^seq[k]
*/

// open output

out.open(lpOutFile);
while(n != data.GetLength()-1)
{
if(n % 2 == 0)
{
dat = (int)szData[n] ^ chbuf[v];
}
else
{
dat = (int)szData[n] ^ chbuf[v] ^ key[n];
}
out << (char)dat;
v--;
n++;
}
out.close();
// close output

// do second encryption

return true;
}

Error:

error C2039: 'get' : is not a member of 'std::basic_ofstream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits
]




filebuf::sh_read
and
ios::nocreate
the code is:

DWORD CCrc32Dynamic::FileCrc32Streams(LPCTSTR szFilename, DWORD &dwCrc32) const
{
#if UNICODE || _UNICODE
return ERROR_NOT_SUPPORTED;
#else
_ASSERTE(szFilename);
_ASSERTE(lstrlen(szFilename));

DWORD dwErrorCode = NO_ERROR;
ifstream file;

dwCrc32 = 0xFFFFFFFF;

try
{
// Is the table initialized?

if(m_pdwCrc32Table == NULL)
throw 0;

// Open the file

file.open(szFilename, ios::in | ios::nocreate | ios::binary, filebuf::sh_read);
if(!file.is_open())
dwErrorCode = file.fail();
else
{
char buffer[MAX_BUFFER_SIZE];
int nLoop, nCount;
nCount = file.read(buffer, sizeof(buffer)).gcount();
while(nCount)
{
for(nLoop = 0; nLoop < nCount; nLoop++)
CalcCrc32(buffer[nLoop], dwCrc32);
nCount = file.read(buffer, sizeof(buffer)).gcount();
}

file.close();
}
}
catch(...)
{
// An unknown exception happened, or the table isn't initialized

dwErrorCode = ERROR_CRC;
}

if(file.is_open()) file.close();

dwCrc32 = ~dwCrc32;

return dwErrorCode;
#endif
}

and for the error for that i get

error C2039: 'nocreate' : is not a member of 'std::basic_ios<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits
]

error C2065: 'nocreate' : undeclared identifier
error C2676: binary '|' : 'const std::_Iosb<_Dummy>::_Openmode' does not define this operator or a conversion to a type acceptable to the predefined operator
with
[
_Dummy=int
]
error C2039: 'sh_read' : is not a member of 'std::basic_filebuf<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits
]
error C2065: 'sh_read' : undeclared identifier


coder requires 0xf00d before continue().

Killer Eagle Software

[edited by - DevLiquidKnight on January 4, 2004 6:28:45 PM]

Share this post


Link to post
Share on other sites

// stdafx.h : include file for standard system include files,

// or project specific include files that are used frequently, but

// are changed infrequently

//


#if !defined(AFX_STDAFX_H__615961CA_1E46_11D6_A1EC_444553540000__INCLUDED_)
#define AFX_STDAFX_H__615961CA_1E46_11D6_A1EC_444553540000__INCLUDED_

#if _MSC_VER > 1000
#pragma once



#endif // _MSC_VER > 1000

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include <math.h>
#include <afxwin.h> // MFC core and standard components

#include <afxext.h> // MFC extensions

#include <afxdisp.h> // MFC Automation classes

#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls

#include <vfw.h>
#include <afxtempl.h>
//#pragma comment(lib, "vfw32")


#ifndef VERSION
#define VERSION "DesktopSecurity v1.0"
#endif
using namespace std;

#endif // _AFX_NO_


//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.


#endif // !defined(AFX_STDAFX_H__615961CA_1E46_11D6_A1EC_444553540000__INCLUDED_)




my encryption class header includes:

#include <math.h>
#include <fstream>
#include "RMD160.h" /* RIPEMD-160 digital signatures */
#include "Blowfish.h" /* Blowfish encryption */


// RMD160.cpp includees

#include "stdafx.h"

/* Header files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "RMD160.h"


// blowfish.cpp includes

#include "stdafx.h"

#include <iostream>
#include <string.h>

#include "Blowfish.h"



There are really alot of files this project I worked on for like a moth or so.... So i wont list all the includes for every file becuase that would probably take forever unless you need them all..

Share this post


Link to post
Share on other sites
Stephen R    721
Sorry dude,

I tried your code with the same headers, in the same order, as you but didn''t get those errors. I have no idea what is going.

Share this post


Link to post
Share on other sites
in my begin message map thingy:
BEGIN_MESSAGE_MAP(CTrayDialog, CDialog)
//{{AFX_MSG_MAP(CTrayDialog)

i have other errors too ....

ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick)
give me:

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


ON_MESSAGE(WM_TRAY_ICON_NOTIFY_MESSAGE,OnTrayNotify)
give me:

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




[edited by - DevLiquidKnight on January 4, 2004 7:00:00 PM]

Share this post


Link to post
Share on other sites