Printing a quoted string
Ali Çehreli
acehreli at yahoo.com
Sun Jan 2 17:33:22 UTC 2022
On 1/2/22 9:27 AM, Amit wrote:
> string s = "one \"two\"\nthree four";
The issue there is that the string does not contain the two characters
\" but the single character ". So, that's a syntax issue. The solution
is to use back ticks to tell the compiler what you really mean.
> And get as output
>
> ```
> "one \"two\"\nthree four"
> ```
import std.stdio;
void main() {
string s = `one \"two\"\nthree four`; // <-- Back ticks
writeln(s);
}
Ali
More information about the Digitalmars-d-learn
mailing list