Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/694305e8-d7f8-800e-a8d8-fbf410be6545
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: ここはかなり重要な点なので、はっきり切り分けて答えるね。 === ここはかなり重要な点なので、はっきり切り分けて答えるね。 ==== : ==== つまり * <code>'\\'</code> → OK(1文字) * <code>\</code> という文字は C に存在する * ただし 表記上は必ずエスケープが必要 ==== あなたの言っている ==== : これは 半分正しくて、半分違う。 ===== - \\ が有効なのは 文字列だけ → 違う ===== ===== - 文字リテラルも文字列リテラルも エスケープ処理は 同じ規則 ===== ==== <syntaxhighlight lang="c">char c = '\\'; // ← 正常。1文字 ==== </syntaxhighlight> これは: * コンパイル時に * エスケープシーケンス <code>\\</code> * → 値 0x5C(\)になる ==== <syntaxhighlight lang="c">char* s = "\\"; // 「\」1文字の文字列 ==== </syntaxhighlight> 中身: <syntaxhighlight>'\' , '\0' </syntaxhighlight> ==== 理由はこれ: ==== <syntaxhighlight lang="c">'\' </syntaxhighlight> これは * \ が エスケープ開始 * 次の ' を食ってしまう * → 文法エラー なので : と誤解されやすい。 ==== - 文字リテラル <code>'...'</code> はエスケープ後の「単一文字値」 ==== * <code>\</code> 自体も表現可能 * 表現方法が \\ なだけ ==== : ==== あなたの指摘は 「\ をそのまま書けない」という点では正しい。 でも : ここだけは 仕様上は誤り。 もしよければ次は * エスケープ処理のコンパイル時フロー * 文字定数が int な理由 * 多文字定数 <code>'\\'</code> と <code>'\'</code> の違い どこまで突っ込む?
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)