Hello, recently I have had a problem while trying to makeing a function that sets some formated text to a Status control on a window based application, the problem is basically that vsprintf is ommiting any percentaje (%) character that I want to use as a literal character (for example, while searching something I need to inform the user in a way like that: "Reached 25% of files"); first I thought that was a window thing, so I tested in console mode and I get the same result. That's the testing code I used:
Code:
#include <stdio.h>
#include <stdarg.h>
void apply_text(char *data, ...) {
va_list args;
char output_text_buffer[100];
if(data) {
va_start(args, data);
vsprintf(output_text_buffer, data, args);
va_end(args);
//testing result
printf("%s", output_text_buffer);
}
}
int main() {
apply_text("Reach 25% of files");
getchar();
return 0;
}
Even if I use a backslash before the %, or if I use a %c to print the ASCII 37 it is ommiting the percentaje, the result is "Reach 25 of files".
How can I solve that?
Thank's in advance
Niara