It has been a while since I have been working with details on specifically appropriately passing parameters into a function. Basically, I have a snippet of code as shown below:
Code:
#define BUFFER_SIZE 5
void main(){
unsigned int temp_res;
char adc[BUFFER_SIZE];
void usart_str_write(char* string);
char Usart_write(char data); // given by built-in library
/* some register assignment commands that's not relevant to the problem */
while(1) {
temp_res = Adc_Read(0);
n = sprintf(adc, "%u", temp_res);
if (n < 0 || n >= BUFFER_SIZE)
break;
usart_str_write(adc);
}
}
void usart_str_write(char* string)
{
while (null character hasn't been reached)
{
Usart_write(string);
string++;
}
}
I'm not sure if I should have my usart_str_write as "void usart_str_write(char* string)" to pass adc[] by reference or by "void usart_str_write(char string[]". Does anyone have an insight on this?