I am very new to Mathematica and I am trying to create a console application using Visual Studio C++. I have followed a example code to see whether it works or not. The codes are as follows.
#include <mathlink.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
MLENV env;
MLINK link;
int errno;
int packet;
env = MLInitialize(0);
/* consider using MLOpenString instead here: */
link = MLOpenArgcArgv(env, argc, argv, &errno);
MLActivate(link);
/* send 42+137 using the full form Plus[42, 137] */
MLPutFunction(link, "Plus", 2);
MLPutInteger(link, 42);
MLPutInteger(link, 137);
MLEndPacket(link);
/* get packets until we find a ReturnPacket or error */
while ((packet = MLNextPacket(link)) && packet != RETURNPKT)
MLNewPacket(link);
if (MLError(link))
printf("error.\n");
else {
int result;
MLGetInteger(link, &result); /* we know that the result is an integer in this case */
printf("result: %d\n", result);
}
getchar();
return 0;
}
When I run this code, it runs and gives me the dialogue boxes below. However, I am not sure what to key in there.
What link am I to create or link to? What am I doing wrong?
Thanks