Hi,
I'm trying to convert a luhn algorithm from C to C++. Here is what I have. I'm having a problem with the main function. I'm not sure where to put it. Here is the code and the compile errors.
Thanks
#include<string.h>
static int verify_checksum(char *credit_card)
{
char *cp;
int dbl;
int check_sum;
check_sum = 0;
dbl = 0;
cp = credit_card + strlen(credit_card) -1;
while (cp >= credit_card)
{
int c;
c = *cp-- -'0';
if (dbl)
{
c *= 2;
if (c >= 10)
c -= 9;
}
check_sum += c;
dbl = !dbl;
}
return ((check_sum % 10) == 0);
}
//eof
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/ccver.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ccver.exe - 2 error(s), 0 warning(s)
[sig][/sig]
I'm trying to convert a luhn algorithm from C to C++. Here is what I have. I'm having a problem with the main function. I'm not sure where to put it. Here is the code and the compile errors.
Thanks
#include<string.h>
static int verify_checksum(char *credit_card)
{
char *cp;
int dbl;
int check_sum;
check_sum = 0;
dbl = 0;
cp = credit_card + strlen(credit_card) -1;
while (cp >= credit_card)
{
int c;
c = *cp-- -'0';
if (dbl)
{
c *= 2;
if (c >= 10)
c -= 9;
}
check_sum += c;
dbl = !dbl;
}
return ((check_sum % 10) == 0);
}
//eof
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/ccver.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ccver.exe - 2 error(s), 0 warning(s)
[sig][/sig]