Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Using a void function to ask user to enter first name.

Author
Message
izic
15
Years of Service
User Offline
Joined: 9th Sep 2009
Location:
Posted: 27th Oct 2009 21:25
Is there some kind of variable I need or something. I not sure how to do this in a void function besides darkgdk. This is what my code looks like so far but its not working

#include "DarkGDK.h"

void getUsersName (char firstname, char lastname);

void DarkGDK()
{
char firstname[35];
char lastname[35];

}
void getUsersName (char firstname, char lastname)
{
char firstname[35];
//Prompt user to enter their first name
dbPrint ("Enter your first name");
strcpy (firstname, dbInput());

char lastname[35];
//Prompt user to enter their last name
dbPrint ("Enter your last name");
strcpy (lastname, dbInput());
}
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 28th Oct 2009 06:12
Did you know you have firstname and lastname declared in your parameter list, inside your function and, apparently, in your "main" function. Which one do you think strcpy is going to put them in?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Drowneath
15
Years of Service
User Offline
Joined: 22nd Jun 2009
Location: In your eyes
Posted: 28th Oct 2009 06:20
You can pass the parameter as reference.

if(asleep) sheep++;
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 28th Oct 2009 14:48
you didnt call the function..and the functon won't work in that way, i think..

try this:

void DarkGDK()
{
char a[35];
char b[35];
getUsersName ( a,b );
}
void getUsersName (char firstname[35], char lastname[35])
{
//Prompt user to enter their first name
dbPrint ("Enter your first name");
strcpy (firstname, dbInput());

//Prompt user to enter their last name
dbPrint ("Enter your last name");
strcpy (lastname, dbInput());
}

Login to post a reply

Server time is: 2024-10-01 16:45:34
Your offset time is: 2024-10-01 16:45:34