Reputation: 3591
I thought it's possible to concatenate strings (char arrays) in C on the fly.
char* str1= "hello" " " "world";
But when I try the following I'll receive an error message (Too few arguments to function fopen). why?
fopen(*argv ".comp", "r");
I want to concat the argument with an char[] constant - without the strcat indirection. Is this possible?
Like the "string".$var in PHP or the "a string like this" + var in Java
Upvotes: 0
Views: 500
Reputation: 143071
You can only concatenate string literals at compile time.
Because compiler has no idea what *argv
is going to be.
Upvotes: 5