Which path format to use in C on Windows, "D:\\source.txt" or "D:/source.txt"? -
i knew can't use d:\demo.txt
\d
considered escape character , hence have use d:\\demo.txt
.but minutes ago found out d:/demo.txt
works fine don't have worry escape characters /
. using codeblocks on windows, , want know 1 of these formats path valid c on platform.here's code , commented-out lines work fine.
#include<stdio.h> int main() { char ch; file *fp,*tp; fp=fopen("d:\\source.txt","r"); //fp=fopen("d:/source.txt","r"); tp=fopen("d:\\encrypt.txt","w"); //tp=fopen("d:/encrypt.txt","w"); if(fp==null||tp==null) printf("error"); while((ch=getc(fp))!=eof) putc(~ch,tp); fclose(fp); fclose(tp); }
windows (like ms-dos before it) requires back-slashes path separator command line tools built into/provided windows.
internal functions, however, have accepted forward or backward slashes interchangeably. personally, prefer forward slashes general rule, it's personal preference -- either works fine.
Comments
Post a Comment