use \\ to link directory and file name

black_snail 2002-09-11 01:05:10
I notice when use fopen to open a file which is not in the current directory . YOu should use \\ to link directory and file name
like fopen("c:\directory\\file.txt ","r")

Can anyone explain the background of this logic . What happen in Unix ?
...全文
85 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
021850524 2002-09-11
  • 打赏
  • 举报
回复
其实在C中用/代替\\就行了
sizhi 2002-09-11
  • 打赏
  • 举报
回复
是的,不仅仅在unix中,windows 也是的
虽然有时'\'也管用,但'\\'安全的多!
blue_coco 2002-09-11
  • 打赏
  • 举报
回复
fopen("c:\\directory\\file.txt ","r")
'\'是C中的转意符
'\\'------>'\'
'\"'------>'"'

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧