I have this simple lcd xc8 header file:
#ifndef XC_PANTALLACWS_H
#define XC_PANTALLACWS_H
#include "lcd.h"
void pantallaCWS (const char stringProyecto){
const char stringProyecto[16] = "__proyNombre____";
Lcd_Init();
Lcd_Out(1, 0, stringProyecto);
}
#endif
What I would like to do is that, if an argument is not given in the function, put one by default.
is this possible?
First, I think there is an error in your argument declaration as it is only one char but you want a string.
Then the trick is to check for a null argument, and if so, provide your default argument in the function, for example:
void pantallaCWS (const char *stringProyecto){
const char *myString;
if (stringProyecto==0)
myString= "__proyNombre____";
else
myString= stringProyecto;
Lcd_Init();
Lcd_Out(1, 0, myString);
}