can you HELP my friend with her C++?

gopunk

Lifer
Jul 7, 2001
29,239
2
0
#include <iostream.h>

const int MAXLENGTH=81; // The maximum credit card entry length

//Function Prototypes
int ValidateCard(char);

int main ()

{
char MyCredit [MAXLENGTH];
cout << "Please enter your credit card number for a fast and accurate validity check.";
cin >> MyCredit [MAXLENGTH];
cout << ValidateCard (MyCredit [MAXLENGTH]);
return 0;
}

that's the source code he gave me, i don't know C++, only C, so i can't help him that much. do you guys see anything blatantly wrong?

he says he's having trouble with his function prototype... can somebody show her how to make one for ValidateCard, whose input is MyCredit and returns a boolean value.

thanks!
 

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
ummm... I see a function prototype, but where is the the function body? Also the type passed to the function should be char* right? She is passing an char array to a function that is the same as passing a char*.
 

AUMM

Diamond Member
Mar 13, 2001
3,029
0
0
aren't C++ and C virtually the same? except for like the scanf,printf/cin, cout?
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
The following code should compile. However, it will not link until the function ValidateCard is defined. And no, C++ is NOT C (though the converse may be true to some extent).

#include <iostream.h>

const int MAXLENGTH=81; // The maximum credit card entry length

//Function Prototypes
int ValidateCard(char*);



int main ()

{
char MyCredit [MAXLENGTH];

cout << "Please enter your credit card number for a fast and accurate validity check:";
cin >> MyCredit;

cout << "\nRESULT:";
cout << ValidateCard (MyCredit);
cout << "\n";
return 0;
}
 

trmiv

Lifer
Oct 10, 1999
14,670
18
81
This has nothing to do with C++, but is this a guy or a girl? You changed a few different times during the post. Started as a girl, then to a guy, then back to a girl. Which is it!! :)
 

PrincessGuard

Golden Member
Feb 5, 2001
1,435
0
0


<< aren't C++ and C virtually the same? except for like the scanf,printf/cin, cout? >>



They are similar in syntax but C++ is object oriented, which is an entire world of difference far beyond cout/printf.

And bool is a valid C++ type, so
bool ValidateCard(char* p);
will work.
 

JMaster

Golden Member
Feb 9, 2000
1,240
0
0
One time in freshman year there was this guy that never came to class and the day before the programming project was due, he shows me his code:

#include <iostream.com>

LMAO!!!!
 



<< can you HELP my friend with her C++? >>





<< he says he's having trouble with his function prototype... can somebody show her how to make one for ValidateCard >>



Him or her?

;)
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
ah you guys caught me.... it's a her but i changed it to a him so that i wouldn't be chastised for not putting a pic there :eek:

i don't have any recent pics of her, sorry guys.
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
huh? like for the help you guys are giving? no, i was on the phone with and she was tearing her hair out so i was like "here, my buddies can help you".... i emailed her a link too. so rest assured, due credit is being given ;)
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0


<< ah you guys caught me.... it's a her but i changed it to a him so that i wouldn't be chastised for not putting a pic there >>



Riiiiiiiiight. In reality, this is really you, but you offered up the idea of helping your friend as you didn't want to feel embarassed if the solution to the problem was really simple.

:)
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
lol, and i'm a he/she ;)

actually i will be taking C++ starting this monday. yay! lets hope i kick ass like i did in C. :D