Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all 3029 articles
Browse latest View live

How to call correct help context in CDialogbar?

$
0
0
Hello,

my problem: pressing the F1-key in a CDialogbar calls WinHelp/HtmlHelp with the wrong help context.
It is the main help context of the app.
How can I call HtmlHelp with the help context of the CDialogbar?

There is no problem if I use a normal CDialog!

thx
ralf

Please help a newbie on CPP High Frequency Trading Example

$
0
0
Hello Everyone,

I am new to this forum and have taken a keen interest in writing trading programs. I have some Python background, a little C# but no C++.

The example below was provided in a book on HFT and I would love to see how the results look. I was hoping that I would just compile it and away you go!

Ahhh..that didn't happen. To start with the author listed this as a function, so I converted it to a main program. Still having issues with my path and where to see the output.

Please help...this should be very interesting for all.

Here it is..
Code:

/*
 PLEASE READ THIS IMPORTANT DISCLAIMER
 This code is distributed AS IS, and is
 not subject to any warranty, performance
 guarantees, etc.

 It is intended strictly for educational
 purposes to illustrate the concepts
 presented in Irene Aldridge's book:
 "High-Frequency Trading: A Practical Guide
 to Algorithmic Strategies and Trading Systems".

 Any commercial distribution of the code is
 strictly prohibited.
 */


 void HFT_AvellanedaStoikov()
 {
 FILE* fin, *fout;
 double lambda_a, lambda_b, d_lambda_a, d_lambda_b;
 int hh = 0, mm = 0, ss, nb = 0, na = 0, prevnb = 0, prevna = 0, prevm = 0;
 double bid, ask, prevbid = 0, prevask = 0;
 char * p1, *p2, buffer[1024], fname[512];
 double gamma = 0.01;
 double optbid = 0;
 double optask = 0;
 char action;
 double portfolio = 0;
 int position = 0;
 double bids[100] = {0}, asks[100] = {0};

 sprintf(fname, "AvellanedaStoikov2008_WFC_InputData.txt"); //download this file from hftradingbook.com
 fin = fopen(fname, "r");
 if(fin)
 {
 sprintf(fname, "AvellanedaStoikov2008_output.txt");
 fout = fopen(fname, "w");
 if(fout)
 {
 //for each event, find the before and after window
 while(fgets(buffer, 1024, fin))
 {
 bid = 0;
 ask = 0;
 sscanf(buffer, "%d\t%d\t%lf\t%lf\n", &hh, &mm, &bid, &ask);

 if(prevm != mm)
 {
 if((nb-prevnb != 0) & (nb != 0) & (prevnb != 0))
 optbid = bid- (1/gamma)*log(1-gamma*(((double)nb)/(double)(nb-prevnb)/prevnb));
 if((na-prevna != 0) & (na != 0) & (prevna != 0))
 optask = ask- (1/gamma)*log(1-gamma*(((double)na)/(double)(na-prevna)/prevna));

 if((optbid > 0) & (optask > 0) & (bid < 0) & (ask < 0))
 {
 if(hh > 15)
 {
 if(position != 0)
 {
 action = 'L';
 //liquidate
 if(position > 0)
 {
 portfolio += position*bid;
 position = 0;
 }
 else if(position < 0)
 {
 portfolio -= position*ask;
 position = 0;
 }
 }
 }
 else
 {
 if(optbid > ask)
 {
 //if(position <= 3)
 {
 action = 'B';
 portfolio -= ask;
 position++;
 }
 //else action = 'N';
 }
 else if(optask < bid)
 {
 //if(position >= -3)
 {
 action = 'A';
 portfolio += bid;
 position--;
 }
 //else action = 'N';
 }
 else
 {
 //between bid and ask
 //if closer to bid, buy
 //else sell
 if(fabs(bid-optbid) < fabs(ask-optask))
 {
 action = 'B';
 portfolio -= ask;
 position++;
 }
 else if(fabs(optbid - bid) > fabs(optask -ask))
 {
 action = 'A';
 portfolio += bid;
 position--;
 }
 }
 }
 //output

 if((na != 0) & (nb != 0) & (prevna != 0) & (prevnb != 0))
 fprintf(fout, "%02d\t%02d\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%c\t%lf\t%d\n",
 hh, mm, bid, ask, (bid+ask)/2, (1/(double)nb), (1/(double)na),
 (double)(nb-prevnb)/prevnb, (double)(na-prevna)/prevna, round(optbid, 2), round(optask, 2),
 action, portfolio, position);
 }
 prevm = mm;
 prevna = na;
 prevnb = nb;
 na = 0;
 nb = 0;
 }

 if((prevbid > 0) & (prevask > 0))
 {
 if(bid != prevbid)
 {
 nb++;
 }
 if(ask != prevask)
 {
 na++;
 }
 }
 prevbid = bid;
 prevask = ask;
 }
 fclose(fout);
 }
 fclose(fin);
 }
 }

Here is some data:

14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.37
14 49 24.37 24.37
14 49 24.37 24.37
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38

[RESOLVED] Newbie needs help

$
0
0
Hi,

First let me say think you in advance to anybody who is willing to take the time to help me out.

I am a VB6 guy from way back but trying to update my programming skills. Rather than tackle vb.net I thought I would try C++. I'm working with Visual C++ 2008.

It's been going pretty well for being only a few days into it but I have run into a difficulty. It's probably a very simple thing for experience programmers but C++ is great divergence from VB6 and I'm a little stuck.

My goal is to output a simple log file. I thought this would work best via a source (cpp) file as opposed to rewriting it for every form. I have created the .h header file and the .cpp file but can't seem to make it work. I've rewritten it 50 times at this point and google searched and dug threw my book but can't seem to figure it out.

I will throw some code out here but I know it's messed up and incomplete so please consider it a starting point.

Here is my CPPLog.cpp source file: (what do I actually need to #include and where and how do I need to innitialize the string?)

#include "stdafx.h"
#include "CPPLog.h"
#include <iostream>
#include <string>
using namespace System::IO;
using namespace System;

String ^ sLog;

void pLogWriter(String ^ sLog){
StreamWriter^ LogFile = gcnew StreamWriter("LogFile.txt");
LogFile->WriteLine(sLog);
LogFile->Close();
}


Here is my CPPLog.h header file: (I get an error saying invalid use of void. I read on some web site you can simply use the keyword string in the declaration but don't know if this is correct.)

#ifndef CPPLOG_H
#define CPPLOG_H

void pLogWriter(string);

#endif


Here is my calling function, or is it method, from main:

#include "CPPLog.h"

pLogWriter("Test");

Thanks again for your help, I greatly appreciate it.

Property Sheets on the main dialog

$
0
0
I have been playing around with property sheets/property pages and have been successful in getting them to work in a secondary dialog by calling the property sheet using DoModal().
I cannot figure out how to get the property sheet to display on the main dialog of a dialog application.
I am using VS2008 and CMFCPropertySheet and CMFCPropertyPage.

[RESOLVED] Property Sheets on the main dialog

$
0
0
I have been playing around with property sheets/property pages and have been successful in getting them to work in a secondary dialog by calling the property sheet using DoModal().
I cannot figure out how to get the property sheet to display on the main dialog of a dialog application.
I am using VS2008 and CMFCPropertySheet and CMFCPropertyPage.

Weird CDBException after SQLBindParameter

$
0
0
Hello,

I'm currently porting a VS2005 C++ application to a 64 bit platform and I'm having a weird issue with some SP calls. The app uses ODBC with an Oracle 11g driver (the 32 bit version used Oracle 10g).

Basically, db->ExecuteSQL("{?=CALL aStoredProcedure }") throws a CDBException with a return code of 99 (found nowhere in ODBC documentation) and an empty error message. The output parameter is bound in the BindParameters method of the database object:

Code:

        void BindParameters(HSTMT hstmt)
        {
                int nRetCode = ::SQLBindParameter(
                        hstmt,
                        1,
                        SQL_PARAM_OUTPUT
                        SQL_C_SLONG,
                        SQL_INTEGER,
                        11,
                        0,
                        (void*)&m_lDbOutParam,
                        0,
                        &m_lBufLength
                );

                ASSERT (nRetCode == SQL_SUCCESS);
        }

I'm thinking moving to 64 bit causes issues with parameter or value types, but I tried several combinations without any success.

Any idea what I'm doing wrong there?

Thanks!

C++ with OOP assignment

$
0
0
Help Please this assignment is due by Sunday 7/20/2014

We will use one source code file to learn how to program object abstractions (commonly referred to as object-oriented classes). We will see how encapsulation, object abstractions, and information hiding are distinct and very significant concepts in C/C++. This should clarify the misunderstandings that result from using object-oriented terms that are appropriate specifically for Object-Oriented Analysis, versus Object-Oriented Design, and Object-Oriented Implementation in C++ .

Please, pay close attention to the threaded discussion posts as they provide key definitions necessary for successfully accomplishing the labs in both coming weeks.

Lab for Week #2

Concerning encapsulation:

Best Definition for OO Design phase:

Encapsulation is the packaging into a single unit highly related states and methods of an entity.

Best definition for implementation phase:

An encapsulation is a proscriptive boundary in the source code such that any interaction across the boundary is allowed by the compiler only if performed in accordance with a formally defined interface. (COMP220 class definition)

The act of proscription is implemented by the compiler's refusal to emit code that access members inside the encapsulation. Instead, the compiler issues a diagnostic: “is private” or “it is not accessible”

The formal interface is the class definition. A class definition always creates a collective type handle known as the name of an OO class. The C++ keywords used to define OO classes are class and struct. Because, classes may be nested,

class1::class2::class3 is a perfectly valid collective type handle.

WARNING: There are special rules for using handles with the same name but of different kind. For example, 1) the name of a constructor is also the name of the class, 2) an object (Object Handle) named identically to a class name (collective type handle) hides the class (never can be instantiated again) for the rest of the program. This is an excellent security feature of C++.

Lab Procedure Week #2

1) Download the source code file named EncapInherit.cpp.
2) As appropriate prepare files required from your development environment.
3) Compile the file and execute it.
4) Study the source code
5) Create a backup copy of the file EncapInherit.cpp.
6) Using the operating system, find out the size of the executable file created by compiling the source code file EncapInherit.cpp.
7) Change all member access specifiers from private or protected to public. Do not change the inheritance access specifiers.
8) (If in an IDE clean the project) recompile and link the program.
9) Repeat step 6 and describe any size changes.
*/
#include "iostream"
using namespace std;

class WritingInstruments
{
protected:
unsigned int RemainingWritingSubstance; // measured in # of chars
public:
explicit WritingInstruments // Do not allow for conversion purposes
( unsigned int AmountOfWritingSubstance = 5 )
{ RemainingWritingSubstance = AmountOfWritingSubstance; }
bool Write( unsigned int NumberOfCharacters2Write )
{
bool Rtn = true;
if( NumberOfCharacters2Write <= RemainingWritingSubstance )
RemainingWritingSubstance -= NumberOfCharacters2Write;
else
{
Rtn = false;
RemainingWritingSubstance = 0;
}
return Rtn;
}
unsigned int LookAtIt() { return RemainingWritingSubstance; }

};

class Pens : public WritingInstruments
{
bool CapIsOn;

public:

explicit Pens(unsigned int Ink = 5, bool CapPassed = true) : WritingInstruments(Ink)
{ CapIsOn = CapPassed;

}

bool Write( unsigned int NumberOfCharacters2Write )
{
if(CapIsOn) return false;
return WritingInstruments::Write( NumberOfCharacters2Write );
// Notice that here we fail to distinguish a failure to write because
// the cap is on from a failure to write because the pen ran out of ink
// Clearly, despite our efforts this inheritance does not meet Liskov's
// sustitution principle. It is possible to meet Liskov if all Pens
// objects are created with the cap off.
}

void LookAtIt() // I violate the encapsulation here
{
cout << "The cap is " << (CapIsOn ? " on " : " off ") << endl;
cout << "and there is enough ink left to write "
<< RemainingWritingSubstance << " characters" << endl;
}
void CapOn(){ CapIsOn = true; }
void CapOff(){ CapIsOn = false; }
};

class Pencils : public WritingInstruments
{
unsigned int RemainingB4Sharpening; // zero means cannot write
public:
const unsigned int CharactersPerSharpenning;

explicit Pencils(unsigned int Lead = 5U, bool TipIsSharp = false,
unsigned int ChPerSharp = 3U)
: WritingInstruments(Lead), CharactersPerSharpenning(ChPerSharp)
{
RemainingB4Sharpening = 0U;
}

bool Write( unsigned int NumberOfCharacters2Write )
{
while (
RemainingB4Sharpening-- &&
RemainingWritingSubstance-- &&
NumberOfCharacters2Write--
);

return !NumberOfCharacters2Write;
}

void Sharpen() { RemainingB4Sharpening = CharactersPerSharpenning; }
};

//------------------------- MAIN ------------------------------



int main()
{
WritingInstruments MyPen(8), YourPen;
// Pens MyPen(8), YourPen;

// MyPen.CapOff(); // Open my pen for writing

for( int i = 1; i <= 5; i++)
{

cout << "\n---------writing for the " << i << "th time ---------\n";

cout << "MyPen: ";
MyPen.LookAtIt();
cout << "\nYourPen: ";
YourPen.LookAtIt();
cout << endl;

if( MyPen.Write(2) )
cout << "\nMy pen successfully wrote 2 more charactrers" << endl;
else cout << "\nMy pen ran out of ink " << endl;

if( YourPen.Write(2) )
cout << "Your pen successfully wrote 2 more charactrers" << endl;
else cout << "Your pen ran out of ink " << endl;
}

system("pause");
return 0;
}

How to Transfer the Particular Content from Notepad to Notepad from VC++

$
0
0
Hi,

I need VC++ code,for copy the particular data from Notepad to another Notepad.
Example, i have lots of data, i need to copy the particular content from Notepad to another Note pad.

Notepad 1:
<Debug: LogRLZ> arg Answer = windows //WINDOWS option will go to excel sheet

<Debug: LogRLZ> arg Answer = patio_doors //patio_doors option will go to excel sheet

<Debug: LogRLZ> arg Answer = entry_doors //entry_doors option will go to excel sheet

Notepad 2_expected Result:

windows

patio_doors

entry_doors

Same kind of datas are available in Notepad.

please provide me the vc++ code.

Thanks
Attached Files

Problem with WinHTTP DLL

$
0
0
I recently installed Visual Studio 2012 and ran this console program.

http://code.msdn.microsoft.com/windo...ample-50a140b5

But while executing, I come across this runtime error

Code:

The procedure entry point WinHttpWebSocketClose could not be located in the Dynamic Link Library WinHTTP.dll
Can someone tell me a solution to this error, and why this error is getting generated?

Thanks in Advance

boost::bind

$
0
0
Can anyone explain (simply) what is meant by the symbols _1, _2, _3 etc, when used with boost::bind(). More importantly - was this supported by MSVC 8?

I'm trying to build some code that has statements like this one:-

Code:

clist.add_connection (_connect (boost::bind (&compositor, _1, _2, _3)));
It works well as long as I only use _1 and _2 - but anything higher than that and I'm seeing messages like:-

Code:

error C2039: '_3' is not a member of boost::lambda
So (for reasons I haven't figured out yet) _1 and _2 are getting interpreted as boost::lambda::_1 and boost::lambda::_2 - but my impression is that _1, _2, _3 etc are simply a parameter list to get passed to the bound function (i.e. they don't have anything to do with boost::lambda). Is this a feature that was only introduced more recently than MSVC 8?

Run in another program

$
0
0
Hello!

I want to make a program which can run in another program.

My program have structures flowing:

while (1)
{
check (keypressed);
{
do something;
}
}

But check(keypressed) function only active in my program, It can't run in another program.
So what shout I do???
Can you help me?


PS: My English is not good.

Message Processing with JavaScript or JQuery

$
0
0
Is there a way I can do message processing between a Win32 application and Javascript using some Windows CallBack function or using Send or Post message?

How to clone an object in C++?

$
0
0
I define two classes in C++, as follows:

class CBaseClass
{
…
}

class CDerivedClass : public CBaseClass
{
…
}

And want to implement a clone function as follows:

CBaseClass *Clone(const CBaseClass *pObject)
{
}

When an object of CDerivedClass is passed to Clone, then the function will also create a CDerivedClass object and return.
When an object of CBaseClass is passed to Clone, then the function will also create a CBaseClass object and return.

How to implement such a feature?

Pass more parameter in overriding new operator

$
0
0
I want to override new operator in C++, by following the instructions at http://www.cprogramming.com/tutorial/operator_new.html

class CMyclass
{
public:
CMyClass(BOOL bUseWhichMemManager);
void* operator new(size_t);
void operator delete(void*);
};

I create two memory manager called CMemManager1 and CMemMangaer2, using different algorithms to allocate buffer. Now I want to control which memory manager to be used, when calling new.

I try to add a parameter bUseWhichMemManager to the constructor, but in overrided new function, there are no way to access the parameter. Is there a way to pass more parameters to new operator, such as:

void* operator new(size_t size, BOOL bUseWhichManager);

Thanks

7 linking errors (LNK2001) compiling (release) emule with vs 2008

$
0
0
Hellow!. My first post is for ask help. These are the 7 errors:

1>Search.obj : error LNK2001: símbolo externo "public: void __thiscall CKademliaWnd::UpdateSearchGraph(class Kademlia::CLookupHistory *)" (?UpdateSearchGraph@CKademliaWnd@@QAEXPAVCLookupHistory@Kademlia@@@Z) sin resolver

1>KademliaWnd.obj : error LNK2001: símbolo externo "protected: virtual int __thiscall CKademliaWnd::OnCommand(unsigned int,long)" (?OnCommand@CKademliaWnd@@MAEHIJ@Z) sin resolver

1>KademliaWnd.obj : error LNK2001: símbolo externo "protected: void __thiscall CKademliaWnd::UpdateButtonTitle(bool)" (?UpdateButtonTitle@CKademliaWnd@@IAEX_N@Z) sin resolver

1>KademliaWnd.obj : error LNK2001: símbolo externo "protected: void __thiscall CKademliaWnd::OnNMDblclkSearchlist(struct tagNMHDR *,long *)" (?OnNMDblclkSearchlist@CKademliaWnd@@IAEXPAUtagNMHDR@@PAJ@Z) sin resolver

1>KademliaWnd.obj : error LNK2001: símbolo externo "protected: void __thiscall CKademliaWnd::OnListModifiedSearchlist(struct tagNMHDR *,long *)" (?OnListModifiedSearchlist@CKademliaWnd@@IAEXPAUtagNMHDR@@PAJ@Z) sin resolver

1>KademliaWnd.obj : error LNK2001: símbolo externo "public: void __thiscall CKademliaWnd::ShowLookupGraph(bool)" (?ShowLookupGraph@CKademliaWnd@@QAEX_N@Z) sin resolver

1>KadContactListCtrl.obj : error LNK2001: símbolo externo "public: void __thiscall CKademliaWnd::UpdateContactCount(void)" (?UpdateContactCount@CKademliaWnd@@QAEXXZ) sin resolver

1>Release_vc9\emule.exe : fatal error LNK1120: 7 externos sin resolver

All errors are related to "KademliaWnd.h", I think. But this file is in the project, as "KademliaWnd.cpp", of course! In addition, if I look the files code, I can see this, for example:

KademliaWind.cpp:
BEGIN_MESSAGE_MAP(CKademliaWnd, CResizableDialog)
...
ON_NOTIFY(NM_DBLCLK, IDC_SEARCHLIST, OnNMDblclkSearchlist)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_SEARCHLIST, OnListModifiedSearchlist)

and in KademliaWnd.h:
DECLARE_MESSAGE_MAP()
...
afx_msg void OnNMDblclkSearchlist(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnListModifiedSearchlist(NMHDR *pNMHDR, LRESULT *pResult);

KademliaWnd.cpp includes KademliaWnd.h, of course.
If it can help, I will post all the files involved in this problem. Many thanks in advance.

Invoke AfxThrowMemoryException cause "Access Violation"

$
0
0
I want to override the operator new in a class, as follows:

class CMyclass
{
public:
void* operator new(size_t);
void operator delete(void*);
};


void* CMyclass::operator new(size_t size)
{
void *p;

p = MemoryManager.Alloc(size); // Using customized memory manager to allocate buffer

if (NULL == p)
AfxThrowMemoryException();
}

However, in debug version, whenever MemoryManager.Alloc(size) returns NULL, which means alloation fails, the AfxThrowMemoryException will cause the following exception:

Access violation reading location 0x#######

How to fix the problem.

Help with Round robin code in c++

$
0
0
After lots of research online and studying various source codes. I thought of trying myself to come up with a way to write the round robin code.
I tried but i get errors in certain part of my output. I am unable to generate the Gaint chart and also please can anyone explain me where i made mistake in calculating my waiting time algorithm.

Can anyone explain me specially how can i get the waiting time of each process and kindly correct my algorithm .Please i have a sincere request. I am a self learner and there is basically no one other than online articles or books to help me understand a code. So, if you correct my mistake, please can you explain me along with the correction. I really want to get the concept because i don't want to do the same mistake again. Thanks.


------- Here is my code --------------

#include<iostream>

using namespace std;

int main()
{
int k,j,q,i,n,ts,temp;
int aw; float awt;
int bt[10],wt[10],te[10],rt[10],at[10];j=0; //te array stores the number of times a process comes to CPU before completion

//bt is my burst time store array
//wt is my waiting time array
//te keeps a count of the number of times a process enters the CPU before completion
//at is the arrival time


cout<<"Enter number of processes"<<endl;
cin>>n;



for(i=0;i<n;i++)
{

cout<<"Enter burst time"<<endl;

cin>>bt[i];

cout<<"Enter arrival times"<<endl;
cin>>at[i];

te[i] = 0; wt[i] = 0;
}

for(i=0;i<n;i++)
{
for(j = i+1;j<n;j++)
{
if(at[j]<at[i])
{
temp = at[i];
at[i] = at[j];
at[j] = temp;
if(at[j] ==at[i])
temp = bt[i];
bt[i] = bt[j];
bt[j] = temp;
}
}
}


cout<<"Enter time slice"<<endl;
cin>>ts;

cout<<"process:"<<endl;


for(i=0;i<n;i++)
{
cout<<"\t"<<i+1<<endl;
}



cout<<"Burst time:"<<endl;
for(i=0;i<n;i++)
{
cout<<" "<<bt[i]<<endl;
rt[i] = bt[i];
}

cout<<"arrival time:"<<endl;
for(i=0;i<n;i++)
{
cout<<" "<<at[i]<<endl;
}

cout<<"Gaint chart"<<endl;

while (j<=n)
{

j++;

for(i = 0;i<n;i++)
{
if(rt[i] ==0) continue;
if(rt[i]>=ts)
{
cout<<"\t"<<q<<i+1<<endl;
q = q + ts;
rt[i] = rt[i] - ts;
te[i] = te[i] + 1;
}

else
{
cout<<" "<<q<<i+1<<endl;
wt[i] = q-te[i]*ts;
q = q +rt[i];
rt[i] = rt[i] - rt[i];
}
}
}

awt = 0;


cout<<"Process Waiting Time"<<endl;
for(i =0;i<n;i++)
{
wt[i] = wt[i] - at[i];
cout<<" "<<i+1<<endl;
cout<<wt[i]<<endl;
awt = awt + wt[i];
}
aw = awt;
cout<<"Total waiting time"<<aw<<endl;
cout<<"Average waiting time "<<awt/n<<endl;

return 0;


}

[RESOLVED] Newbie needs help

$
0
0
Hi,

First let me say think you in advance to anybody who is willing to take the time to help me out.

I am a VB6 guy from way back but trying to update my programming skills. Rather than tackle vb.net I thought I would try C++. I'm working with Visual C++ 2008.

It's been going pretty well for being only a few days into it but I have run into a difficulty. It's probably a very simple thing for experience programmers but C++ is great divergence from VB6 and I'm a little stuck.

My goal is to output a simple log file. I thought this would work best via a source (cpp) file as opposed to rewriting it for every form. I have created the .h header file and the .cpp file but can't seem to make it work. I've rewritten it 50 times at this point and google searched and dug threw my book but can't seem to figure it out.

I will throw some code out here but I know it's messed up and incomplete so please consider it a starting point.

Here is my CPPLog.cpp source file: (what do I actually need to #include and where and how do I need to innitialize the string?)

#include "stdafx.h"
#include "CPPLog.h"
#include <iostream>
#include <string>
using namespace System::IO;
using namespace System;

String ^ sLog;

void pLogWriter(String ^ sLog){
StreamWriter^ LogFile = gcnew StreamWriter("LogFile.txt");
LogFile->WriteLine(sLog);
LogFile->Close();
}


Here is my CPPLog.h header file: (I get an error saying invalid use of void. I read on some web site you can simply use the keyword string in the declaration but don't know if this is correct.)

#ifndef CPPLOG_H
#define CPPLOG_H

void pLogWriter(string);

#endif


Here is my calling function, or is it method, from main:

#include "CPPLog.h"

pLogWriter("Test");

Thanks again for your help, I greatly appreciate it.

NPAPI Plugin VC++

$
0
0
Is it possible to create an NPAPI Plugin in VC++, that is cross browser compatible or should atleast work in Chrome Browser?

If yes can someone show me some example?

Problem with WinHTTP Socket Application

$
0
0
I am running this WinHTTP-WebSocket Application in a Windows 8.1 platform with Visual Studio 2013.

http://code.msdn.microsoft.com/windo...a140b5#content.

But while running this application, I come across Error 12029 which is generated while calling WinHttpSendRequest function.

Can someone tell me a solution to this?
Viewing all 3029 articles
Browse latest View live


Latest Images