Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • C language Help using Dirent.h

    help question
    25
    0 Votes
    25 Posts
    4 Views
    D
    Nothing personal, but this code looks all kinds of convoluted. When iterating the items in the folder pointed to by argv[1], how are you determining if an item is a file or a folder? [edit] Upon further inspection, I now see that code in dirent.h is a wrapper for this. My bad. [/edit] I suspect you need to be using the _findfirst()/_findnext() pair, or _stat() at the very minimum. It's been ages since I've used the former, but I envision something like: void processFile( const char *pFile ) { // however you need to handle 'pFile' would go here } //==================================================================== void processFolder( const char *pFolder ) { char *p = (char *) malloc(strlen(pFolder) + 5); strcpy(p, pFolder); strcat(p, "\\*.*"); struct \_finddata\_t fileinfo; intptr\_t handle = \_findfirst(p, &fileinfo); if (handle != -1) { do { if (fileinfo.attrib & \_A\_SUBDIR) { if (fileinfo.name\[0\] != '.') processFolder(fileinfo.name); } else processFile(fileinfo.name); } while(\_findnext(handle, &fileinfo) == 0); \_findclose(handle); } free(p); } //==================================================================== void main(int argc, char* argv[]) { if (argc == 2) processFolder(argv[1]); } Obviously this does not solve your overall problem, but you can't bother with checking the contents of a file before you have successfully iterated a folder. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Simple anti virus project (Argv FILE* dirent.h)

    com debugging tools help tutorial
    13
    0 Votes
    13 Posts
    1 Views
    A
    I did calculate the bytes and the characters as i needed it needs to be 24 bytes when at the last code i posted you can see that until i reach to the point that is /1 its 23 bytes the + 1 is the one i added so it will be the end of the string
  • Driver Memory Usage

    performance question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    4 Posts
    1 Views
    L
    Just in case you are genuine, please read http://www.codeproject.com/Messages/2922875/HOW-TO-ASK-A-QUESTION.aspx[^]. No one here is going to help you decrypt anything.
  • binary trees using a dynamic arrays

    data-structures design tutorial
    3
    0 Votes
    3 Posts
    0 Views
    L
    Your design.
  • Modification of xls file

    tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    F
    I think courier new all the characters are the same width I'll read the doc Thanks
  • 0 Votes
    2 Posts
    0 Views
    L
    ForNow wrote: Does this make any sense ? Not really. Everything on a PC is also a byte (or a word ...). The only time the format of a character has any real relevance is when you display it on some output device. So when writing to your device context, you must first create a font and select it into the DC. See https://msdn.microsoft.com/en-us/library/w6196kz3.aspx[^] for some more details. See also http://www.functionx.com/win32/Lesson15.htm[^] for a sample using Win32, but you should be able to get enough information to use that in MFC.
  • sort million input

    css com help
    3
    0 Votes
    3 Posts
    0 Views
    enhzflepE
    Well then, you'd better hop-to-it and get writing then don't you? There's countless examples of sorting code on the web. If you cant even be bothered to search for them, and instead ask to be spoon-fed,you're not going to enjoy programming much - it's an occupation that required copious amounts of research. Also, you might wish to edit your question to remove your email address - you'll get email notifications if someone replies anyway - providing your email just provides opportunity for others to inconvenience you. :doh: "When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
  • Copy Text from dialog box

    tutorial
    5
    0 Votes
    5 Posts
    0 Views
    D
    So if the dialog box belongs to your app, and you are populating the controls on it, then don't you already have access to the text? "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Drive Start Sector using WMI services

    2
    0 Votes
    2 Posts
    0 Views
    F
    In the extended partitions the meaning of partition table entries are different from that of standard partitions. You may want have a look to this[^] MS article.
  • Exception in code C

    data-structures debugging help
    7
    0 Votes
    7 Posts
    1 Views
    P
    And test one function at a time for each case. Put breakpoint in each branch and ensure you test each one or better yet, make unit test for each one. Philippe Mori
  • DialogBox Create Fails

    c++ help
    4
    0 Votes
    4 Posts
    0 Views
    L
    The assert fails because the CWnd* does not point to an object that contains a valid Window handle. Something in your code has not been initiailised correctly, or you are calling Create from outside of a Window class. What class is Show_storage?
  • An analog switch, but more efficient

    database data-structures help learning
    2
    0 Votes
    2 Posts
    0 Views
    J
    Have a gander here[^]. Pay particular attention to #11. "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
  • Property Grid alignment issue with sub-group

    c++ css com help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • The Cheesy Animation Factory - 3D Architectural Solution

    html com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Calculating average in a high priority thread

    game-dev help question
    6
    0 Votes
    6 Posts
    0 Views
    J
    See this Stackoverflow thread: http://stackoverflow.com/questions/10990618/calculate-rolling-moving-average-in-c-or-c[^]. The fastest solution would be a ring buffer and a total sum variable (untested): int items = 0; int ndx = 0; int buffer[buffer_Size]; // May need floating point here when max. value * buffer_size >= INT_MAX int sum = 0; int get_av(int val) { if (items >= buffer_size) sum -= buffer[ndx]; else ++items; sum += val; buffer[ndx] = val; if (++ndx >= buffer_size) ndx = 0; return sum / items; } This should be fast enough for your requirements
  • A simplest assembly error - need help

    help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • MFC release and Debug build

    c++ debugging help announcement learning
    6
    0 Votes
    6 Posts
    0 Views
    M
    My mistake. (the linked article can still offer hints and tips). I'd rather be phishing!
  • is it possible to...

    question learning
    4
    0 Votes
    4 Posts
    0 Views
    A
    Member 11675472 wrote: code my website so when new customers sign up, they are automatically sign up for the hundrends of websites listed on my website/platform ? :omg: Hundreds? :wtf: Just because you can doesn't mean you should.
  • C++ code to manage 3 keypads connected to one PC?

    c++ tools help tutorial question
    9
    0 Votes
    9 Posts
    0 Views
    M
    Excellent point.