Reputation: 2427
fd1 = open("/dev/test_kft" "1",00);
What does "/dev/test_kft" "1"
mean?
Upvotes: 5
Views: 147
Reputation: 118680
The explicit form in C is this:
char part1[] = "/dev/test_kft";
char part2[] = "1";
char path[strlen(part1) + strlen(part2) + 1];
strcpy(path, part1);
strcat(path, part2);
This still does not replicate the fact that the "implicit" concatenation form is place in the rodata segment. In the example I've given, it'll be on the stack. You could put it on the heap with malloc. The implicit version is done at compile time, and preferred if possible.
Upvotes: 0
Reputation: 2619
The preprocessor concatenates adjacent string literals, so that line is the same as
fd1 = open("/dev/test_kft1", 00);
Upvotes: 4
Reputation: 799300
It's implicit concatenation as performed by the compiler. It results in "/dev/test_kft1"
.
Upvotes: 10