Thursday, July 30, 2009

Unable to add <iostream> and sprintf in VC7(vs2003) Class library?

Hi i just created a Class library(dll) project in VS-2003 (VC++.Net)


If I add using namespace std %26amp;


#include %26lt;iostream%26gt;


it keeps giving me error.


I am unable to use sprintf also


please guide. me but same code works well in VC++ exe


pls find the code.


#include "stdafx.h"


#include %26lt;winsock2.h%26gt;


#include %26lt;iostream%26gt;


using namespace std;


#using %26lt;mscorlib.dll%26gt;


#include %26lt;stdlib.h%26gt; // For exit() call


#include %26lt;windows.h%26gt;


#pragma comment (lib, "wsock32.lib") // Visual C++ -%26gt; Include library


SOCKET GSocket;


using namespace System;


//#pragma comment (lib, "wsock32.lib") // Visual C++ -%26gt; Include library


struct msg_head


{


char flag[4];


char len[4];


char ver[4];


char terminal[8];


char serv[8];


char dlg_id[8];


char dlg_ctrl[6];


char dlg_ext[4];


char tx_id[8];


char tx_ctrl[6];


char tx_ext[4];


} *msg;


......


sprintf((char*)%26amp;msg-%26gt;flag ,"%-4.4s" ,"`SC`" );


......

Unable to add %26lt;iostream%26gt; and sprintf in VC7(vs2003) Class library?
I can't help you with VC7. I'm a microsoft hater, so I don't know why iostream would give you problems, but sprintf is a C function in stdio.h, so you should be including %26lt;cstdio%26gt;. See if that eases your problem.
Reply:Sprint sucks (tm).


No comments:

Post a Comment