Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
F

Frankie C

@Frankie C
About
Posts
48
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Waiting for open files
    F Frankie C

    Look this[^] and this[^].

    C / C++ / MFC help

  • Waiting for open files
    F Frankie C

    Let me understand: 1. you don't open the files in your program, but you create a new process to run an app that open the file. 2. You are not waiting on a file, but on the process to end. So if the process opens multiple files you got no notifications. If this is the scenario maybe you have to use a different strategy to be notified right on files changes. Check the directory change notifications[^] ;)

    C / C++ / MFC help

  • Waiting for open files
    F Frankie C

    Giovanni they already explained to you that WaitForSingleObjects returns with the index of the event in the array that has been set. When you get it simply inspect the return value, identify the file and execute the operations sequential to file closure. Then remove the event from the array then repeat the WaitForSingleObjects with one element less in array. Repeat it until there are no more events in the array. Buona fortuna.

    C / C++ / MFC help

  • Use #define or enum in switch() case(s) ?
    F Frankie C

    No you don't have to declare enum volatile, and the compiler should give you error. This because you are creating an enumerated series of constants and they can't change. You must declare volatile your input variable, because this is the one that changes under interrupt. You must do this to advice the compiler to take care when optimizing code to make no assumptions on its value. If you don't there will be cases in which the compiler will assume that the variable is in a specific condition and will omit some code or use an old value.

    C / C++ / MFC question tutorial

  • Event objects VS Global variables
    F Frankie C

    Don't post questions on many places. You already posted it here[^].

    C / C++ / MFC visual-studio

  • UPS, U.P.S., Uninterrupted Power Supply // Surge Protection
    F Frankie C

    First of all always look for well known suppliers, that will give you half the guarantee. Then look for a true sinusoidal UPS, which means that the output is sinus shaped resembling the line waveform. The cheaper square-wave devices can create problems to switching power supplies of PC and other electronic devices. For more or less the same reason check the minimum allowed load power factor, this parameters directly deals with current phasing of inductive loads, but for electronic devices lower power factors means that the UPS can tolerate higher waveform distortion and the harmonics generated, again, by switching power supplies of electronic devices. If you are looking for medium-high power UPS's looking at characteristics you'll find also an harmonic THD distortion, the lower the best. About surge protection don't worry too much, an UPS device by default give surge protection: A surge is a fast transient overvoltage of power line (up to 200-250% of nominal value), because an UPS output is controlled and regulated you should be theoretically free from them. Another important characteristic is the autonomy: how many minutes of power it can deliver at nominal power. This defines the dimensions of the battery pack. Choose the right time you need, the batteries are very expansive and are also delicate. Remember that batteries have a lifespan (that depends very much on ambient temperature, higher the temperature shorter the life), good quality batteries will guarantee a life of 18-24 months at 25°C +/-2°C.

    Hardware & Devices sales help tutorial question learning

  • UPS, U.P.S., Uninterrupted Power Supply // Surge Protection
    F Frankie C

    First of all always look for well known suppliers, that will give you better guarantee. Then look for a true sinusoidal UPS, which means that the output is sinus shaped resembling the line waveform. The cheaper square-wave devices can create problems to switching power supplies of PC and other electronic devices. For more or less the same reason check the minimum allowed load power factor, this parameters directly deals with current phasing of inductive loads, but for electronic devices lower power factors means that the UPS can tolerate higher waveform distortion and the harmonics generated, again, by switching power supplies of electronic devices. If you are looking for medium-high power UPS's looking at characteristics you'll find also an harmonic THD distortion, the lower the best. About surge protection don't worry too much, an UPS device by default give surge protection: A surge is a fast transient overvoltage of power line (up to 200-250% of nominal value), because an UPS output is controlled and regulated you should be theoretically free from them. Another important characteristic is the autonomy: how many minutes of power it can deliver at nominal power. This defines the dimensions of the battery pack. Choose the right time you need, the batteries are very expensive and are also delicate. Remember that batteries have a lifespan (that depends very much on ambient temperature, higher the temperature shorter the life), good quality batteries will guarantee a life of 18-24 months at 25°C +/-2°C.

    Hardware & Devices sales help tutorial question learning

  • need help with linked structs at C language
    F Frankie C

    Thanks.

    C / C++ / MFC com help

  • need help with linked structs at C language
    F Frankie C

    There are a lot of errors and redundant code. See the following solution, study it and go on on yourself now.

    void deleteNode(numStruct **firstNode, numStruct *nodeToDelete)
    {
    numStruct *temp = NULL;

    if (!\*firstNode)
    	return;	//Empty list
    
    // Special case the node we must delete is the first one
    if (\*firstNode == nodeToDelete)
    {
    	temp = \*firstNode;
    	\*firstNode = (\*firstNode)->Next;
    	free(temp);
    	return;
    }
    
    for (numStruct \* currNode = \*firstNode; currNode->Next; currNode = currNode->Next)
    {
    	if (nodeToDelete == currNode->Next)
    	{
    		temp = currNode->Next;
    		currNode->Next = (currNode->Next)->Next;
    		free(temp);
    		return;
    	}
    }
    

    }

    void RemoveNodes(numStruct **anchorNode)
    {
    numStruct *t = *anchorNode;
    int arr[50] = {0};
    int spot = 0;

    printf("Please enter all the numbers you want to delete and end it with - 999 \\n");
    
    for (spot=0; spot < 50; spot++)
    {
    	fflush (stdin);
    	scanf("%d", &arr\[spot\]);
    	if (arr\[spot\] == -999)
    		break;
    }
    
    if (spot >= 50)
    	spot--;
    
    for (int i = 0; i < spot; i++, t = \*anchorNode)
    {
    	while (t != NULL)
    	{
    		if (t->number == arr\[i\])
    		{
    			deleteNode(anchorNode, t);
    			break;
    		}
    		t = t->Next;
    	}
    }
    

    }

    int main(void)
    {
    numStruct *anchorNode = NULL;
    numStruct *newNode = NULL;
    AddSongs(&anchorNode, newNode);
    printList(anchorNode);

    RemoveNodes(&anchorNode);
    printList(anchorNode);
    
    system("PAUSE");
    

    }

    C / C++ / MFC com help

  • need help with linked structs at C language
    F Frankie C

    Because just the first variable anchorNode must be passed as pointer to struct pointer to have it assigned. Also AddSongs must pass it directly to insertAtEnd(). I report the whole program here:

    #include #include #include struct numberNode {
    int number;
    struct numberNode *Next;
    };

    typedef struct numberNode numStruct;

    numStruct *createSong(int numbers)
    {
    numStruct *newSong = (numStruct *)malloc(sizeof(numStruct));
    if (newSong)
    {
    newSong->number = numbers;
    newSong->Next = NULL;
    }
    return newSong;
    }

    void insertAtEnd(numStruct **firstNode, numStruct *newNode)
    {
    numStruct *currNode = *firstNode;

    // if the linked list is empty
    // should put the new node as the first
    if (!currNode)
    {
    	\*firstNode = newNode;
    	newNode->Next = NULL;
    }
    else
    {
    	while (currNode->Next)	// problem at the second loop
    	{
    		currNode = currNode->Next;
    	}
    
    	currNode->Next = newNode;
    	newNode->Next = NULL;
    }
    printf("\\n\\n");
    

    }

    numStruct *AddSongs(numStruct **anchorNode, numStruct *newNode)
    {
    int count = 0;
    int numbers;

    printf("\\nPlease enter numbers and at the end enter -999\\n");
    
    do
    {
    	count++;
    	//flushall();
    	fflush(stdin);
    	numbers = 0;
    
    	printf("\\n\\n%d.\\n\\nnumber: ", count);
    	scanf("%d", &numbers);
    
    	if (numbers != -999)
    	{
    		newNode = createSong(numbers);
    		insertAtEnd(anchorNode, newNode);
    	}
    }
    while (numbers != -999);
    printf("\\n\\n");
    return NULL;
    

    }

    void printList(numStruct *firstNode)
    {
    numStruct *currSong = firstNode;
    printf("\n\n-------------------------------------\n");
    while (currSong)
    {
    printf("number= %d \n", currSong->number);
    currSong = currSong->Next;
    }
    printf("-------------------------------------\n\n");
    printf("\n\n");
    }

    int main(void)
    {
    numStruct *anchorNode = NULL;
    numStruct *newNode = NULL;
    AddSongs(&anchorNode, newNode);
    printList(anchorNode);

    system("PAUSE");
    

    }

    Check it against your code. We pass a pointer to a variable when we want access the variable from the called function, in your case to assign to anchorNode the beginning of the memory list.

    C / C++ / MFC com help

  • why 4 twice
    F Frankie C

    You got this result because the optimizations are on. The compiler choose an optimization that leads to the final result not considering what the values could be in the same call. This is consistent with C99, C11 and C++11 standards that to privilege the best optimization of code state that the order of evaluation of the parameters of a function is undefined, and compiler dependent (but also situation dependent different conditions of optimization will lead to different results). If you test your code with different compilers you'll get different results. Please consider that even with optimizations off the compiler could give 'strange' values. BTW the more common output you should expect should be '4 3', because the parameters should normally be evaluated from right to left (incrementing 2 to 3 and pushing it on the stack, then incrementing it to 4 and pushing it on the stack). When optimization are on basically the compiler decides to make a double increment in one time (instead of move back to the same variable for a second increment).

    C / C++ / MFC question

  • need help with linked structs at C language
    F Frankie C

    Your code is almost correct, just a couple of errors in the main function. The variable newNode have to be initialized to NULL to avoid errors and compiler complainings. anchorNode and NewNode are already pointer to structures of type numStruct, so you have to pass them directly to AddSongs(), but you're passing their address (even if this sounds strange to me because you should have got a compiler error). The correct code is this:

    int main(void)
    {
    numStruct* anchorNode = NULL;
    numStruct* newNode = NULL;
    AddSongs(anchorNode, newNode);

    system("PAUSE");
    

    }

    C / C++ / MFC com help

  • Drive Start Sector using WMI services
    F Frankie C

    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.

    C / C++ / MFC

  • Easyhook error:STATUS_INVALID_PARAMETER_4:The given 32-Bit library does not exist!<Code: 2>
    F Frankie C

    你好 (Hello) You have to post in the EasyHook page comments here[^] (at end of article).

    Windows API help dotnet com question

  • Base 36 value math problem
    F Frankie C

    Thanks Matt, I put it up too fast. I corrected it with a version that acts like standard libc conversion routines, and can be used for any base.

    Algorithms csharp help tutorial question

  • Base 36 value math problem
    F Frankie C

    A base 36 numbering scheme should be the math rappresentation of a normal numer expressed with 36 different ciphers. :) It should be quite an easy task to create a function that converts the strings that you have to plain binary numbers (base 2) understandable to the computer. This function is equivalent to an ascii to bin conversion, only the symbols that have top be handled are 36. The sequence, I suppose, is: 0 1 2 3 4 5 6 7 8 9 A B C D E F G . . . . . Z The generic rappresentation of a number expressed in base x is: Vn*X^n + V(n-1)*X^n-1 + V(n-2)*X^n-2 + ... + V(0) In plain the sum of all ciphers by the power of the base at the position taken as exponent. This is sample to convert a base 36 number to a base 2 numberEDIT: This sample converts any ascii rappresentation of a number in all bases between 2 and 36. It acts as the standard atoi, atol, etc. It converts all applicable characters up to the end of string or the first non number with respect to the choosed base. If the first string char is not a valid cipher, or the string is empty it returns NULL.

    long long GenRadVal(char *str, int base)
    {
    if (base<2 || base>36)
    return 0LL;

    long long val = 0;
    
    for (int i = 0; str\[i\]; i++)
    {
    	int c = toupper(str\[i\]);
    	if ((c < 0) || ((c > '9') && (c < 'A')) || (c > 'Z'))
    		break;
    	c =  c > '9' ? c - 'A' + 10 : c - '0';
    	if (c >= base)
    		break;
    	val \*= base;
    	val +=  c;
    }
    return val;
    

    }

    This will give you back a 64 bits number equivalent to the string. To go back to the original value you can use itoa() function in C. Now comparisons are easy.. :laugh: P.S. the reverse for this function is the stdlib function itoa() with base=36.

    Algorithms csharp help tutorial question

  • MapViewOfFIle in Client and Server returning 2 different address
    F Frankie C

    Technically: the physical memory is the same, but the MMU maps it to available free logical address in the destination process. :)

    C / C++ / MFC sysadmin

  • InterProcess communication questions
    F Frankie C

    No you don't need to duplicate handle if you have enabled inheritance int the CreateEvent of parent process setting lpEventAttributes parameter. You need a duplicated handle if the event is created in the child process. For detailed info see[^].

    C / C++ / MFC

  • Multiple Client Support Server Application designed with Windows Named Pipes hangs frequently
    F Frankie C

    Nobody is answering because in the other thread you have been requested to reformat your code to make it readable, but you stll left it as is also here...

    Windows API sysadmin

  • Exe file compatibility
    F Frankie C

    They already gave you some good links. Anyway if your problem is to understand if the exe structure itself is compatible between last 5 Os's the answer is yes. The executable format (PECOFF) is the same as the resources format. More different is the situation from system calls point of view. If an exe using very 'basic' functions can happily run from NT4.0 to WIN10, the things changes as you use new functions from OS or libraries (ie MFC) that were not present in former releases. So if you want to know if your exec from VC2008 under XP will run on Win7 and Win8 it will do it on 99% of cases. Instead if you want to build an exe that can run on all OS's from NT on carefully choose the functions you use in your code (or prefer API programming). P.S. The graphical aspect can be changed between the OS's using an external manifest file with the compatibility fields correctly compiled allowing each OS to use last version of GUI DLL's.

    C / C++ / MFC csharp c++ visual-studio question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups