Click to See Complete Forum and Search --> : passing char array


scarlson
February 1st, 2003, 08:34 AM
Hello,
Disclaimer: First time post. Lousy C programmer, but forced into a project.

This seems simple but, within a function I declare a char array and then try to pass it, work on it , and then get it back:
void InitialFunction()
{
char keyboard_input[20];
//do some wori and then...
keyboard_input = ReadTheKeyboard(keyboard_input);
}


and within the second function I do this:

char ReadTheKeyboard(char keyboard_input[20])
{
//here i do my work and I can verify it is okay
return(keyboard_input);
}

This causes compiler issues. So sorry to be a dolt, but how do I pass a char array, work on it, and get it back?

Secondly, if I do this multiple times, how do I "empty" or "clear" the array "keyboard_input" before I use it again?

Note: I use my own keyboard input routine and can verify that it works properly.

Again, first time using this forum. I hope you can help. If I have done anything totally incorrect, I apologize.

Thank you.

mwilliamson
February 1st, 2003, 10:42 AM
void InitialFunction()
{
char keyboard_input[20];
ReadTheKeyboard(keyboard_input,20);
}

void ReadTheKeyboard(char* keyboard_input,size_t size)
{
/// clear keyboard input
memset( keyboard_input, 0, size );
/// modify keyboard_input here
}