mysql_go
mysql_go

Reputation: 2427

What does it do to juxtapose string literals next to each other?

fd1 = open("/dev/test_kft" "1",00);

What does "/dev/test_kft" "1" mean?

Upvotes: 5

Views: 147

Answers (3)

Matt Joiner
Matt Joiner

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

tJener
tJener

Reputation: 2619

The preprocessor concatenates adjacent string literals, so that line is the same as

fd1 = open("/dev/test_kft1", 00);

Upvotes: 4

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799300

It's implicit concatenation as performed by the compiler. It results in "/dev/test_kft1".

Upvotes: 10

Related Questions