Shorty code with range based loops I need an example on writing this code with range based loops:

int pListPet[2] = {34001, 34051};   

int pListGlobal[] = {9001, 9002, 9003, 9004, 9005, 9006, 20011, 20091, 20092, 20093, 20094, 20095, 30000};

const char* strMapListGlobal[] = {"string1" , "string2"};

const char* strMapEventOx = "string3";                              

std::string stringName = CPythonBackground::Instance().GetWarpMapName();

for (int i = 0; i &lt; _countof(strMapListGlobal); i++)
{
    #ifdef CHECK_STRING_3
    if (strMapEventOx == stringName)
    {
        if (0 &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= 7)
            return FALSE;
    }
    #endif

    if (strMapListGlobal[i] == stringName)
    {
        for (int i = 0; i &lt; _countof(pListGlobal); i++)
        {
            if (rVictim.GetRace() == pListGlobal[i] || pListPet[0] &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= pListPet[1])
                return FALSE;
        }
    }   
}


Do you think this correctly uses std::string? Can this be optimized more or maybe written shorter?

Should I use this?

if (!strcmp(strMapEventOx, stringName))
Range for can be used with iterators, including pointers, as follows

for (auto name: strMapListGlobal)
{
    #ifdef CHECK_STRING_3
    if (strMapEventOx == stringName)
    {
        if (0 &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= 7)
            return FALSE;
    }
    #endif

    if (name == stringName)
    {
        for (auto p: pListGlobal)
        {
            if (rVictim.GetRace() == p ||
                pListPet[0] &lt;= rVictim.GetRace() &amp;&amp; 
                rVictim.GetRace() &lt;= pListPet[1])
                return FALSE;
        }
    }   
}


Your program needs further refinement. Upon inspection, we see that the first conditional inside the loop body

if (strMapEventOx == stringName)
{
    if (0 &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= 7)
            return FALSE;
}


is invariant inside the loop and can be factored out.
That leaves us with the following

for (auto name: strMapListGlobal)
{
    if (name == stringName)
    {
        for (auto p: pListGlobal)
        {
            if (rVictim.GetRace() == p ||
                pListPet[0] &lt;= rVictim.GetRace() &amp;&amp; 
                rVictim.GetRace() &lt;= pListPet[1])
                return FALSE;
        }
    }   
}


To further refine your program, eliminate raw pointers. Not knowing what your macros do it is difficult to say but you might consider. 

auto pets = std::vector&lt;int&gt; { 34001, 34051 };   

auto globalPets = {
    9001, 9002, 9003, 9004, 
    9005, 9006, 20011, 
    20091, 20092, 20093, 
    20094, 20095, 30000
};

auto globalEventNames = { "string1" , "string2" };

auto eventOx = "string3";                              

auto mapName = CPythonBackground::Instance().GetWarpMapName();

#ifdef CHECK_STRING_3
if (eventOx == mapName)
{
    if (0 &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= 7)
        return FALSE;
}
#endif


for (auto event: globalEventNames)
{
    if (event == mapName)
    {
        for (auto pet: globalPets)
        {
            if (rVictim.GetRace() == pet || pets[0] &lt;= rVictim.GetRace() &amp;&amp; rVictim.GetRace() &lt;= pets[1])
                return FALSE;
        }
    }   
}


as for strcmp 

if (strcmp(strMapEventOx, stringName))


avoid it!

if (strMapEventOx == stringName)


is more readable, more idiomatic, and likely faster.