-1

I want to add ~ (tilde) in the string and write this string to a file.

Eg.

String = "~Hi~Welcome ~Presenting ~My~Problem~To~you Public ~L.",
ile:write_file(WriteFileName, io_lib:fwrite(String,[])).

Error received

** Reason for termination == 
** {badarg,[{io_lib,format,
                    ["~Hi~Welcome ~Presenting ~My~Problem~To~you Public ~L.",
                     []],
                    [{file,"io_lib.erl"},{line,168}]},.....]}

Any Help Appreciated! Thanks :)

legoscia
  • 39,593
  • 22
  • 116
  • 167
nikdange_me
  • 2,949
  • 2
  • 16
  • 24

2 Answers2

2

You don't need the call to io_lib:fwrite there; you can just pass the string to file:write_file directly:

String = "~Hi~Welcome ~Presenting ~My~Problem~To~you Public ~L.",
file:write_file(WriteFileName, String).
legoscia
  • 39,593
  • 22
  • 116
  • 167
1

Use two of them:

1> io:format("~~~s~~~s~~~n", ["Hello", "World"]).
~Hello~World~
ok

From the io:fwrite/1 documentation:

Available control sequences:

~

Character ~ is written.

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380