Carraige Return Problem in char array with new compiler


Is there a compiler option to recognize and ignore carraige returns and line feed within a char array.

This is occuring with char strings that have been translated to other languages.

The following code compiled fine with our old compiler but does not with
our new one. (there is a CR in the middle of the translated string)

I'm looking for a compiler option or other ideas.

static const char* test = "€T|ûg
R¡NºTX";
You should probably post the code.

oic

umm i thnk it needs to be this

static const char *test[number long plus null] = "text here";

Thats is exactly the code....its translated to a diff language , thus looking goofy
and causing the compiler errors , but compiles fine with our older compiler.

Here is the exact code again to be clear. (thanks)

static const char* test = "€T|ûg
R¡NºTX";
In C and C++, you quote a newline by putting a backslash before it.

1
2
3
4
5
6
7
8
9
10
#include <iostream>

const char* s = "This string is split\
into two lines, but prints as one.";

int main()
  {
  std::cout << s << std::endl;
  return 0;
  }

If you simply want to code the string on separate lines, you can split it arbitrarily and the compiler will automatically join the pieces.

1
2
3
4
5
6
7
8
9
10
#include <iostream>

const char* s = "This string is also only"
                " one line of text.";

int main()
  {
  std::cout << s << std::endl;
  return 0;
  }

You can also embed a newline in the string using the '\n' character sequence.

1
2
3
4
5
6
7
8
9
#include <iostream>

const char* s = "This string prints\nas two lines.";

int main()
  {
  std::cout << s << std::endl;
  return 0;
  }

Hope this helps.
Topic archived. No new replies allowed.