Helpful Information
 
 
Category: Beginner Programming
problems compiling program in VC++

Hi,

I'm currently a student taking C++. I found some old C code that I'm trying to convert tom C++. Here is the code with the corresponding error messages. I hope someone can help.
Thanks,
Cyber_Op

#include<string.h>
void main()
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

errors:

C:Program FilesMicrosoft Visual StudioMyProjectsccverccver.cpp(3) : warning C4518: 'static int ' : storage-class or type specifier(s) unexpected here; ignored
C:Program FilesMicrosoft Visual StudioMyProjectsccverccver.cpp(3) : error C2146: syntax error : missing ';' before identifier 'verify_checksum'
C:Program FilesMicrosoft Visual StudioMyProjectsccverccver.cpp(3) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

ccver.obj - 2 error(s), 1 warning(s)










privacy (GDPR)