|
FredrickNorge wrote: My idea is that this function either returns true if the file is present, or false if its not, any sugestions?
_access(..., 0) sounds a whole lot simpler.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In additinal yo can use of FindFirstFile
|
|
|
|
|
FredrickNorge wrote:
My idea is that this function either returns true if the file is present, or false if its not, any sugestions?
try PathFileExists
<div class='ForumSig'>"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you </div>
|
|
|
|
|
I need some help about the code i must write so the program will compare the files of 2 folders and find the number of the different files. thanks in advance.
|
|
|
|
|
pro.log wrote: ...different files.
Which could be any number of things (e.g., size, date, contents). Please elaborate.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
just for the contents of the 2 folders
|
|
|
|
|
So just add the contents of each folder to its own array. If the size of the arrays are different, or if one array has an item that the other does not, then you know the folders are indeed different.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi Forum,
Is it possible to write a simple hello world win32 application which is statically linked with kernel32 and ntdll? When I run the ap, only the executable image should be in memory and no other modules (including the kernel32/ntdll which are normally loaded). I want to build a fully self-contained executable. Is that doable?
Thanks in advance for any information.
|
|
|
|
|
sunriseway wrote: I want to build a fully self-contained executable. Is that doable?
Short answer: no.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
So I see a lot of code like this lately:
sprintf(pUserPwd, "%s", oVerifedWriteDlg.m_UserPwd);
Why use that instead of just going with strcpy?
strcpy(pUserPwd, oVerifedWriteDlg.m_UserPwd);
Am I missing something?
I am inclined to think the sprintf would be a lot slower ...
|
|
|
|
|
My personal preference would me to use strcpy() , unless I was constantly changing what I wanted in pUserPwd (e.g., padding, numbers, justification, additional variables).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Laziness is the main culprit there. The sprintf version is far more likely to introduce buffer overrun bugs (e.g. if the wrong delimeter is used).
Note that the safer operations are actually to use the std::string class, or at the very least, the strncpy function (or its variants).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
If you are writing for Windows only (not cross-platform) you should use the safe string routines
strcpy == StringCchCopy[^]
led mike
|
|
|
|
|
led mike wrote: If you are writing for Windows only (not cross-platform) you should use the safe string routines
strcpy == StringCchCopy[^]
Or the slightly more familiar (syntax-wise) replacements: strXXX_s
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
yes they are also safe versions but are not all the same as the strsafe library routines
You should be aware that strsafe functions, such as StringCchCopy and StringCchCat behave
differently than strncpy_s and strncat_s. If strncat_s detects an error, the function will
set the string to NULL. However, by default, strsafe will fill the destination with as much
data as possible, and then NULL-terminate the string. You can mimic the same behavior in
strsafe with code like this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncode/html/secure03102004.asp[^]
led mike
|
|
|
|
|
I'd side step the whole issue and use a string class such as std::string or CString .
Steve
|
|
|
|
|
Hi there I am trying to understand some C++ code. I know the code below outputs "k=3 l=4". I would've thought that "++k+ ++k" would evaluate to "6", I don't see how "l" equals "4", can anyone explain this to me?
<br />
<br />
void main()<br />
{<br />
int k=3;<br />
int l;<br />
<br />
l = sizeof(++k+ ++k);<br />
<br />
printf("k=%d l=%d", k ,l);<br />
}<br />
<br />
Thanks in advance.
|
|
|
|
|
|
CaptainChainsaw wrote: Hi there I am trying to understand some C++ code.
It's actually just C; nothing C++ about it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
l = 4 because the sizeof function returns the length in bytes of a data structure or primitive. k is an integer and integers on your machine are 4 bytes long.
|
|
|
|
|
c/c++ does not define syntax for result - avoid things like that always.
|
|
|
|
|
Hi all, thank you for your replies. I understand what is going on now!
Cheers!
|
|
|
|
|
CaptainChainsaw wrote: l = sizeof(++k+ ++k);
The sizeof is returning the size of an integer (4 bytes).
The expression ++k + ++k is undefined in the standard, but on most compilers will result in k = 5 (with an initial value of 3). That said, you should avoid using such expressions as they are both undefined and make your code highly unreadable.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi.
I'm developing a MFC ActiveX Control with some buttons on it, and I want to show some tooltips for each control.
Well, I used the code that MSDN help, offer for showing tooltips for control in a dialog box, (using CTooltipCtrl) but it did not work. Just nothing happened.
Where is the problem? Maybe, because I have COleControl derived class instead CDialog class.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
I will go ahead and ask the obvious. Did you override PreTranslateMessage?
Oh... just read Active X control. I do not know if PreTranslateMessage applies in this case. Might be worth a look though.....
|
|
|
|