#define and strings
Hello,
I would like to create a string constant with a #define and concatenate it with another string. I thought doing this: #define USB blabla static char[256] = {"/"USB"5"}; in hope to print this --> "/blabla5" What is the rightn way to do? Please, I need your help. Raf |
Quote:
|
Hey,
Quote:
Code:
char *str = "String1" "String2"; // "String1String2" Quote:
Code:
#define USB "blabla" - Andi - |
yes but why?
it's a bit naff. Code:
#include <stdio.h> been done |
|
Quote:
Unlike normal parameter replacement, the argument is not macro-expanded first. This is called stringification. That's how you could theoretically do it in C with macros: Code:
#define UBS blabla |
Quote:
Code:
char str[256] Something like Code:
const char * const str = ...; |
Hey,
yes, you're completely right. I was just copying the initial code, but your approach is much better :-) - Andi - |
What about the case that if the code modifies it later?
|
Quote:
|
Thank you very muche ForzaItalia2006!
That was exactly what I was looking for, something simple and quite close to wath I usually do with integers. Quote:
Raf |
All times are GMT -5. The time now is 10:21 AM. |