C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
# define Posted by johnjitu on 26 Mar 2009 at 8:03 AM
can i define paths
Report
Re: # define Posted by Lundin on 26 Mar 2009 at 8:38 AM
Sure, go ahead.

What do you mean by "path"? An access path to a directory or file? Those are just strings, so yes you can #define those, but a const char array is cleaner.
Report
Re: # define Posted by johnjitu on 26 Mar 2009 at 8:45 AM
#define PATH C:\windows\notepad.exe

Is this code is correct ?
Report
Re: # define Posted by VampireFE on 26 Mar 2009 at 9:05 AM
Almost :) 2 problems with it:

1. You'll want to put the path in "" since it's a text string.
2. Since \ is an escape symbol, you need to put 2 of those if you want one backslash.

Like this:
#define PATH "C:\\windows\\notepad.exe"
Report
Re: # define Posted by johnjitu on 27 Mar 2009 at 1:00 AM
Thanks very much .



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.