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
C

C3D1

@C3D1
About
Posts
10
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C++ expression(s)
    C C3D1

    Oh my god... The MFC MESSAGE_MAP... How could i miss this rape on #define-macros and the whole C++ Language...

    The Weird and The Wonderful c++ question

  • C++ expression(s)
    C C3D1

    isn't that a C++ 11 feature? I'm currently using the VC6 compiler... There is no C++ 11 :java: ;P

    The Weird and The Wonderful c++ question

  • C++ expression(s)
    C C3D1

    Today i found some really weird expression in some C++-code

    if(++(k=j) != node.end())
    {
    if("something" == *k)
    doSomething();
    else if("something other" == *k)
    doSomethingOther();
    }

    and just ~30 lines below that weird if statement i found this:

    k = j;
    if(++k != node.end())

    {
    if("something" == *k)
    doSomething();
    else if("something other" == *k)
    doSomethingOther();
    }

    why always so weird? Why don' to it in an nice way

    k = j + 1;
    if(k != node.end())

    {
    if("something" == *k)
    doSomething();
    else if("something other" == *k)
    doSomethingOther();
    }

    In some other code a few days ago i found this

    n[idx++] = a[++idx2]++;

    where both, a and n, are defined as void* What are the ugliest C++ expressions that have you seen in the last few weeks/months

    The Weird and The Wonderful c++ question

  • Fun with pointers in C++
    C C3D1

    totally agree with you. But always use const can cause some other problems. I personally try to avoid "pointer-getter-functions" but when i have to use, i do something like this:

    class Foo
    {
    private:
    int m_nA;

    public:
    int* GetAPtr() { return &m_nA; }
    const int& GetA() const { return m_nA; }
    void SetA(int nA) { ASSERT(IsValid(nA)); m_nA = nA; }
    };

    And if i have to use the pointer-getter i have to write Ptr explicit. So i see extremly fast that

    *GetAPtr() = *GetBPtr();

    is nonesense, and if you try to do

    GetA() = GetB();

    you get a compiler-error Maybe my way overshot the mark a litte bit. ;P :-\

    The Weird and The Wonderful c++ question

  • Fun with pointers in C++
    C C3D1

    Sorry, that's not my code, an i cant change it. I just saw it in some code and where surprised what's that :D Returning references would make it much harder to read:

    GetA() = GetB()

    looks like What the hell? Assignment to a Function? :omg: :wtf:

    The Weird and The Wonderful c++ question

  • Fun with pointers in C++
    C C3D1

    Today i come across this two lines of code (i changed the naming of the functions):

    // ...
    if(GetA() && GetB())
    *GetA() = *GetB();
    // ...

    took me nearly two hours of figuring out WHY DOES THIS CODE WORK, since i realised thatGetA() returns a Pointer and Pointers are IValue... Looked deeper inside the code, i found a SetA(int)-Method... Why to use something like

    *GetA() = *GetB()

    if you could use

    SetA(*GetB())

    The Weird and The Wonderful c++ question

  • Friday Programming Challenge
    C C3D1

    Just to make sure i'm understanding everything right. You want to convert CIDR notation to dotted decimal?! My approach is to convert the CIDR to a binary string (eg. /8 = 11111111000000000000000000000000), then split this string to the octets in an array (eg. [0]=11111111 [1]=00000000 [2]=00000000 [3]=00000000) and then converting each octet to decimal. Sample source in C#:

    public enum IP_TYPE
    {
    IPv4
    , IPv6
    }

    public String convertCIDR2DottedDecimal(int nCIDR, IP_TYPE eType)
    {
    // Build Binary String
    int nBits = (eType == IP_TYPE.IPv4) ? 32 : 128;
    String sBinary = "";

    for(int nIdx = nCIDR - 1; nIdx >= 0; nIdx--)
    	sBinary += "1";
    
    for(int nIdx = nBits - nCIDR; nIdx >= 0; nIdx--)
    	sBinary += "0";
    
    // Split Binary String to Octets
    int nOctets = (eType == IP\_TYPE.IPv4) ? 4 : 16;
    String\[\] aOctets = new String\[nOctets\];
    
    for(int nIdx = 0; nIdx < nOctets; nIdx++)
    {
    	String sOctet = "";
    	for(int nOctetIdx = 0; nOctetIdx < 8; nOctetIdx++)
    	{
    		sOctet += sBinary\[nOctetIdx\];
    	}
    
    	sBinary = sBinary.Substring(8);
    
    	// Convert each Octet to Decimal
    	aOctets\[nIdx\] = "" + Convert.ToInt32(aOctets\[nIdx\], 2);
    }
    
    return String.Join(".", aOctets);
    

    }

    The Lounge database tutorial career learning

  • Launch Safari from another app then Autofill username and password
    C C3D1

    to my knowledge this is not possible. I saw some password tools (like 1Password, LastPass) on the appstore that opens up a website on an internal browser and then fill in the username and password. But to my knowledge apple doesen't allow IPC between most of the Apps. The only place where Apps are communicating is AppleHealth where 3th party apps could write to AppleHealth. If you find a way to opening up safari and then fill in the user and password boxes i'm extremly interested in the solution! :)

    Objective-C and Swift ios design question

  • Are MFC Timer(s) bad for performance in large projects (Vc++)
    C C3D1

    Hey out there, i'm heared that the use of timers in large projects is bad for performace. So is this true? I'm wondering, because i have done a new control using VC++/MFC and i use one timer in there. The timer only is created and the first time it's called i terminate it. Now someone said to me that i sould use ::GetTickCount() instead and save the first value and compare it again and again. It look more performance hungry than my timer solution. So what's your oppinion? Please don't answer something like i should do a test, i haven't so much time to test such things. And please answer only real facts and not only stuff like "i like timers more because i like it more" or "i like the TickCount solution more". Hope for a good discussion :)

    C / C++ / MFC c++ performance question discussion

  • Are MFC Timer(s) bad for performance in large projects (Vc++)
    C C3D1

    Hey out there, i'm heared that the use of timers in large projects is bad for performace. So is this true? I'm wondering, because i have done a new control using VC++/MFC and i use one timer in there. The timer only is created and the first time it's called i terminate it. Now someone said to me that i sould use ::GetTickCount() instead and save the first value and compare it again and again. It look more performance hungry than my timer solution. So what's your oppinion? Please don't answer something like i should do a test, i haven't so much time to test such things. And please answer only real facts and not only stuff like "i like timers more because i like it more" or "i like the TickCount solution more". Hope for a good discussion :)

    ATL / WTL / STL c++ performance question discussion
  • Login

  • Don't have an account? Register

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