Naufuge Posted December 31, 2005 Share Posted December 31, 2005 (edited) #include <iostream> using namespace std; bool path = "C:\\WINDOWS\\system32\\d2.CSParser.dll"; int main(void){ static bool Exists(path); if (Exists = true){ cout<<"EXISTS\n"; cin.get(); } if (Exists = false){ cout<<"DOESNT EXIST\n"; cin.get(); } } im using Microsoft Visual C++ 2005 Express Edition. shouldnt this code work to test if a file exists?? it only returns "true" even if the file isnt there Edited December 31, 2005 by Naufuge Link to comment Share on other sites More sharing options...
Developers Jos Posted December 31, 2005 Developers Share Posted December 31, 2005 (edited) bool path = "C:\\WINDOWS\\system32\\d2.CSParser.dll";bool ? Edited December 31, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Naufuge Posted December 31, 2005 Author Share Posted December 31, 2005 a bool returns a value of "true" or "false" Link to comment Share on other sites More sharing options...
Developers Jos Posted December 31, 2005 Developers Share Posted December 31, 2005 a bool returns a value of "true" or "false"Understand, but this line defines a variable containing a string so assume it must be a CHAR ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 bool path = "C:\\WINDOWS\\system32\\d2.CSParser.dll";I can't believe the compiler doesn't issue a warning (under W3) but it doesn't. At any rate, like page 2 of any book should of conveyed the point that C++ is a typed language and that trying to stuff a string into a bool isn't going to work like you think.static bool Exists(path);I don't understand what you think this is supposed to do (Well, I do, but I don't understand how you got the idea that C++ works that way). It is declaring a new static boolean variable named "Exists" and initializes it with the value of the global boolean variable "path".if (Exists = true){This is an assignment statement, C++ uses == for equality comparison.cout<<"EXISTS\n";Should be: cout<<"EXISTS"<<endl; // Adds newline and flushes the streamif (Exists = false){Again, assignment is performed, not an equality test.cout<<"DOESNT EXIST\n";Again, need endl, not \n.I suggest you go back and start reading some C++ books again from the beginning. About the only thing you did right was get the function signature for main() right which is admirable given the other basic mistakes you made. Link to comment Share on other sites More sharing options...
Naufuge Posted December 31, 2005 Author Share Posted December 31, 2005 Fine then, if your so smart, you make it work! Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 Why? So then you'll have your answer and be just as ignorant on C++ as you are right now? Do you want to learn C++ or do you just want a program done for you? If it's the former, put forth some effort and read some (good) books on the subject. If it's the latter, piss off, you're not going to find anybody here to write your code. Link to comment Share on other sites More sharing options...
Naufuge Posted December 31, 2005 Author Share Posted December 31, 2005 all i did was ask why something wasnt working, then asked if you could get it to. i NEVER said write my code for me, SO U PISS OFF! Link to comment Share on other sites More sharing options...
WSCPorts Posted December 31, 2005 Share Posted December 31, 2005 (edited) Again i will say this Valik :needs: to refrain from posting to a thread to once his second(planned) reply to outrage isnt needed. but we are what we are and nothing more or less so take the worlds opinion with a grain of salt .;P read for the answers not for the crap that wraps it :l Edited December 31, 2005 by WSCPorts http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32] Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 (edited) all i did was ask why something wasnt working, then asked if you could get it to.i NEVER said write my code for me, SO U PISS OFF!No, what you said was:Fine then, if your so smart, you make it work!Quick English lesson for you. Questions have... wait for it... question marks (? <-- That symbol). I see no question mark, ergo, the sentence is in the form of a declarative statement. Not only that, it reads very much like an order since you are telling me to "make it work" since I'm "so smart". That remark in addition to your other thread in which you are trying to get people to translate some AutoIt code into C++ makes me highly suspicious of your desire to learn C++.Again i will say this Valik :needs: to refrain from posting to a thread to once his second(planned) reply to outrage isnt needed.What are you on about? Edit: Incidentally, judging by your reaction and given that I provided you with the optional path of having the benefit of the doubt in my previous post, it's clear that you are in fact not interested in learning C++ at this time. Edited December 31, 2005 by Valik Link to comment Share on other sites More sharing options...
layer Posted December 31, 2005 Share Posted December 31, 2005 It's the internet, chill. I think Valik has mentioned "pay attention to the content of my message and not the way I deliver it" quite a few times now. FootbaG Link to comment Share on other sites More sharing options...
Naufuge Posted December 31, 2005 Author Share Posted December 31, 2005 dude, forget it... who cares anymore. ive only been trying to learn C++ for maybe (and thats a BIG maybe) 3 months. and only reading these cheesy "C++ DeMYSTiFieD" books. so lets chill out and be adults. will you help me learn, (not do it for me) but teach me? Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 I have been completely chilled the entire time. All you had to do from the beginning was explain that you had crappy books and ask for good ones. Search the Chat and Developer's forum for "C++ Books" and you should find several posts by me where I mention good (free) books for learning C++. You desperately need some good books and if you are serious about learning the language, seeking out some of the books in the posts you find will be a great start. Link to comment Share on other sites More sharing options...
Stumpii Posted December 31, 2005 Share Posted December 31, 2005 Why is this even here? It has absolutely nothing to do with AutoIt! Naufuge, you should find a good book on C++, available from most good bookshops. Try and find a C++ forum to post questions to. Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity. Link to comment Share on other sites More sharing options...
Nutster Posted January 1, 2006 Share Posted January 1, 2006 While you are looking for better C++ books, many good business and community colleges (some of them may even be in your area) have courses on programming, including courses on object-oriented design and programming using C++ or Java. If you are in the Toronto, Canada area, you may even take one of mine. If you are still in high school, please talk with the computer science teachers; some of them probably took those courses at university, particularily the one with a BSc, not a BA. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Naufuge Posted January 1, 2006 Author Share Posted January 1, 2006 i would talk with some teachers, except my high school is poor and cant even afford a Structured Programming class. i will, on the other hand, search the forums for C++ books...also i found "The Waite Group C++ Primer Plus" book at my local library, which i am reading now. Link to comment Share on other sites More sharing options...
Nutster Posted January 2, 2006 Share Posted January 2, 2006 (edited) I would talk with some teachers, except my high school is poor and cant even afford a Structured Programming class.i will, on the other hand, search the forums for C++ books...also i found "The Waite Group C++ Primer Plus" book at my local library, which i am reading now.Just because they do not teach the course does not mean that the teachers do not know it. I know enough to teach high school physics, chemistry, mathematics, calculus, computer science, but I only teach classes for computer programming and databases in a career college setting, but that does not mean I have forgotten the other stuff. So go ahead and ask you teachers for some help.I have some other Waite Group books. They are generally well written. Good luck with your self-enlightenment. I recommend picking up The Ansi-C programming language by Kernihan and Richie for some good background and practices in a traditional (non-object oriented) data model and an excellent reference. Edited January 2, 2006 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Naufuge Posted January 2, 2006 Author Share Posted January 2, 2006 thanks, ill ask some of my teachers when i go back, were on winter break right now... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now