Who finds it first... [closed] : [modified]
-
**std::string stSroucePath;** std::string stDestPath; setSourcePath(&stSourcePath); setTargetPath(&stDestPath); if((stSourcePath.size==0)||(stDestPath.size==0))
stSroucePath ... it should be stSourcePath ... it is a typo? Em i right? -- modified at 5:42 Tuesday 17th July, 2007 -
Hey, I saw that! I was fairly sure it was C++, but noticed size didn't have the parantheses. That's why I said the language looks alien. I was looking for a runtime error. :| But Swathi can have your beer; I'm a teetotaller. ;P
Cheers, Vıkram.
After all is said and done, much is said and little is done.
-
Hey, I saw that! I was fairly sure it was C++, but noticed size didn't have the parantheses. That's why I said the language looks alien. I was looking for a runtime error. :| But Swathi can have your beer; I'm a teetotaller. ;P
Cheers, Vıkram.
After all is said and done, much is said and little is done.
-
Hey, I saw that! I was fairly sure it was C++, but noticed size didn't have the parantheses. That's why I said the language looks alien. I was looking for a runtime error. :| But Swathi can have your beer; I'm a teetotaller. ;P
Cheers, Vıkram.
After all is said and done, much is said and little is done.
There are many objects that expose values through member variables, so when you mix them up with the objects that uses functions to return values, you'll get confused. In particular when the object supports both ways.
Vikram A Punathambekar wrote:
But Swathi can have your beer; I'm a teetotaller.
Hey that's actually an apple juice filled in a beer cup ;P
-
**std::string stSroucePath;** std::string stDestPath; setSourcePath(&stSourcePath); setTargetPath(&stDestPath); if((stSourcePath.size==0)||(stDestPath.size==0))
stSroucePath ... it should be stSourcePath ... it is a typo? Em i right? -- modified at 5:42 Tuesday 17th July, 2007admirm wrote:
stSroucePath ... it should be stSourcePath ... it is a typo? Em i right?
says the guy with a typo in his user name - shouldn't it be
admin
? :laugh:Regards, mav -- Black holes are the places where God divided by 0...
-
std::string stSroucePath; std::string stDestPath; setSourcePath(&stSourcePath); setTargetPath(&stDestPath); if((stSourcePath.size==0)||(stDestPath.size==0))// should be `size()`swati m spots it! :-D happy coding dude ;) { prompt("Set the Directory paths!"); //Added! } else { int nRes = examineFile(stSourcePath.c_str()); if(nRes>0) { moveFilesToDest(&stDestPath); vec_stMovedFiles.push_back(&stDestPath); vec_stMovedFiles.push_back(stDestPath); return; } switch(nRes) { case -1: prompt("Protected!"); break; case -2: ... . . . } }
Find the dumb little evil bug inside..(Don't worry about the purpose of the code) It doesn't throw any exception but will screw up your application silently.
That's why I use
std::string.length
:) (or was it length() :doh:) -
std::string stSroucePath; std::string stDestPath; setSourcePath(&stSourcePath); setTargetPath(&stDestPath); if((stSourcePath.size==0)||(stDestPath.size==0))// should be `size()`swati m spots it! :-D happy coding dude ;) { prompt("Set the Directory paths!"); //Added! } else { int nRes = examineFile(stSourcePath.c_str()); if(nRes>0) { moveFilesToDest(&stDestPath); vec_stMovedFiles.push_back(&stDestPath); vec_stMovedFiles.push_back(stDestPath); return; } switch(nRes) { case -1: prompt("Protected!"); break; case -2: ... . . . } }
Find the dumb little evil bug inside..(Don't worry about the purpose of the code) It doesn't throw any exception but will screw up your application silently.
How does stSourcePath.size==0 even compile?! Also, is something wrong here: vec_stMovedFiles.push_back(&stDestPath); return; You are storing the address of a stack variable followed immediately by a return. The use of the variable must be after the return, at which point the variable is no longer valid.
-
How does stSourcePath.size==0 even compile?! Also, is something wrong here: vec_stMovedFiles.push_back(&stDestPath); return; You are storing the address of a stack variable followed immediately by a return. The use of the variable must be after the return, at which point the variable is no longer valid.
Please check my reply to Optimus Chaos Linkety[^] actually I modified/typed the code here online just to make it simpler to understand. I just copied the string name from the previous line, so the "&" thing came along!
dighn wrote:
You are storing the address of a stack variable followed immediately by a return. The use of the variable must be after the return, at which point the variable is no longer valid.
Yup I know :). The reason just explained above.
-
How does stSourcePath.size==0 even compile?! Also, is something wrong here: vec_stMovedFiles.push_back(&stDestPath); return; You are storing the address of a stack variable followed immediately by a return. The use of the variable must be after the return, at which point the variable is no longer valid.
-
How does stSourcePath.size==0 even compile?! Also, is something wrong here: vec_stMovedFiles.push_back(&stDestPath); return; You are storing the address of a stack variable followed immediately by a return. The use of the variable must be after the return, at which point the variable is no longer valid.
dighn wrote:
How does stSourcePath.size==0 even compile?!
IIRC, VC++ 6.0 would let things like this compile.