How do I write strings across lines in C/objective-C?

Asked 2 years ago, Updated 2 years ago, 42 views

const char *sql_query = "SELECT statuses.word_id FROM lang1_words, statuses WHERE statuses.word_id = lang1_words.word_id ORDER BY lang1_words.word ASC";

Very long queries together

const char *sql_query = "SELECT word_id
                        FROM table1, table2
                        WHERE table2.word_id = table1.word_id
                        ORDER BY table1.word ASC";

I'd like to split into.

There's an error on the chord right now Please tell me the easiest way to split a string

objective-c c

2022-09-22 22:22

1 Answers

C uses a backslash (\) when dividing a line into multiple lines.

char *my_string = "Line 1 \
                   Line 2";
NSString *my_string = @"Line1 \
                        Line2";
char *my_string = "Line 1 "
                  "Line 2";
NSString *my_string = @"Line1 "
                       "Line2"; // You may or may not add @ from the second time


2022-09-22 22:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.