I hope my question can be answered here, because it excludes the ++ part of C.
I have created a function that receives a string as a parameter, and I want to pass a formatted string to it without having to create a temporary variable, but I don't know how. I've made it work using sprintf but I have to waste a variable for that. We're talking MCUs here so one variable matters.
The function's prototype is based on printf's one, as I need per character control, and it worked for a simple string without % signs. void lcd_string (constunsignedchar * DATA)
I've tried this: lcd_string("%u", 15);
, but the compiler says there are too many function arguments.
Then I tried this: lcd_string(("%u", 15));
, but the compiler gives a warning about illegal conversion from integer to pointer, but compiles anyway. But upon runtime, the debugger complains an infinite times (while the function is only called once) about stack overflow on CALL instruction and stack underflow on RETURN instruction.
Also tried on Code::Blocks:
invalid conversion from 'int' to 'const char*'
I'm using HTC's Hi-Tech C Compiler for PIC MCUs which, according to them, follow C standards.