0

I am trying to store a multiline string so I can loop over them like the example below:

...............#.#.............
##..#....................#...##
......#..#.#.....#..#.#.##.....
.........#...#..............#.#
............#.......##.........
...#.....#.....#...#.....#..#..
..............#..##.#..#......#
.##.....#.....#......##.#......
.#..........###....#...##....#.
.....#....#.#.......#......##..
.#....#......#.......#........#
..#.#.......#..##.....##.......
...#.#....#.......#.......#...#
##.##...##..#......#.#.....#..#
.#.#.......#..#.#......#...#.#.
#.......##.......#...#.........
.....#......#.#.#.....#....##..
.#.#........#....#..#..#.......
...#....#..###.........#.....#.

In Python I would do the following :

example = """
...............#.#.............
##..#....................#...##
......#..#.#.....#..#.#.##.....
.........#...#..............#.#
............#.......##.........
...#.....#.....#...#.....#..#..
..............#..##.#..#......#
.##.....#.....#......##.#......
.#..........###....#...##....#.
.....#....#.#.......#......##..
.#....#......#.......#........#
..#.#.......#..##.....##.......
...#.#....#.......#.......#...#
##.##...##..#......#.#.....#..#
.#.#.......#..#.#......#...#.#.
#.......##.......#...#.........
.....#......#.#.#.....#....##..
.#.#........#....#..#..#.......
...#....#..###.........#.....#.
"""

I tried using std::string s("") with the entire string inside of it but I get a lot of errors saying error: invalid preprocessing directive.

yudhiesh
  • 6,383
  • 3
  • 16
  • 49
  • 1
    By "multiline string" do you mean a string that, as far as code (e.g. library functions) using it is concerned, has multiple lines? Or do you mean a string that has an initialiser in source code that spans multiple lines? The options are different in both cases. – Peter Dec 04 '20 at 04:12
  • 1
    [Raw string literal](https://en.cppreference.com/w/cpp/language/string_literal) might be useful to you as well. – user4581301 Dec 04 '20 at 04:13
  • @Brian yes thank you that worked. – yudhiesh Dec 04 '20 at 04:14

0 Answers0