Click here to Skip to main content
15,908,843 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: SendMessage for Interprocess communication stops working Pin
leon de boer2-Nov-16 3:10
leon de boer2-Nov-16 3:10 
GeneralRe: SendMessage for Interprocess communication stops working Pin
ForNow2-Nov-16 14:32
ForNow2-Nov-16 14:32 
GeneralRe: SendMessage for Interprocess communication stops working Pin
leon de boer2-Nov-16 16:57
leon de boer2-Nov-16 16:57 
QuestionNeed help with cryptography Pin
SMD1111-Nov-16 8:54
SMD1111-Nov-16 8:54 
AnswerRe: Need help with cryptography Pin
Randor 1-Nov-16 19:04
professional Randor 1-Nov-16 19:04 
Question[C]Problem in creating a random string Pin
xXxRevolutionxXx27-Oct-16 1:31
xXxRevolutionxXx27-Oct-16 1:31 
AnswerRe: [C]Problem in creating a random string Pin
Richard MacCutchan27-Oct-16 1:46
mveRichard MacCutchan27-Oct-16 1:46 
GeneralRe: [C]Problem in creating a random string Pin
k505427-Oct-16 4:47
mvek505427-Oct-16 4:47 
GeneralRe: [C]Problem in creating a random string Pin
Richard MacCutchan27-Oct-16 4:55
mveRichard MacCutchan27-Oct-16 4:55 
AnswerRe: [C]Problem in creating a random string Pin
Jochen Arndt27-Oct-16 2:35
professionalJochen Arndt27-Oct-16 2:35 
AnswerRe: [C]Problem in creating a random string Pin
leon de boer27-Oct-16 3:43
leon de boer27-Oct-16 3:43 
SuggestionRe: [C]Problem in creating a random string Pin
David Crow27-Oct-16 4:48
David Crow27-Oct-16 4:48 
GeneralRe: [C]Problem in creating a random string Pin
Daniel Pfeffer27-Oct-16 5:11
professionalDaniel Pfeffer27-Oct-16 5:11 
AnswerRe: [C]Problem in creating a random string Pin
Krishnakumartg27-Oct-16 20:18
Krishnakumartg27-Oct-16 20:18 
GeneralRe: [C]Problem in creating a random string Pin
k505428-Oct-16 4:59
mvek505428-Oct-16 4:59 
PraiseRe: [C]Problem in creating a random string Pin
Krishnakumartg30-Oct-16 18:50
Krishnakumartg30-Oct-16 18:50 
QuestionRe: [C]Problem in creating a random string Pin
David Crow31-Oct-16 2:31
David Crow31-Oct-16 2:31 
QuestionUsing COM in DLL called by .Net application Pin
Leif Simon Goodwin26-Oct-16 3:02
Leif Simon Goodwin26-Oct-16 3:02 
AnswerRe: Using COM in DLL called by .Net application Pin
Richard Deeming26-Oct-16 3:11
mveRichard Deeming26-Oct-16 3:11 
PraiseSOLVED Pin
Leif Simon Goodwin9-Nov-16 5:32
Leif Simon Goodwin9-Nov-16 5:32 
AnswerRe: Using COM in DLL called by .Net application Pin
«_Superman_»26-Oct-16 20:47
professional«_Superman_»26-Oct-16 20:47 
GeneralRe: Using COM in DLL called by .Net application Pin
Leif Simon Goodwin8-Nov-16 20:53
Leif Simon Goodwin8-Nov-16 20:53 
QuestionError in returning array of int as reference Pin
Korowai22-Oct-16 19:35
Korowai22-Oct-16 19:35 
Hi, i have to ask a question about some codelines, where i have a mistake, because the array of int always returns 1 for every instance and i spent a lot of hours and still cannot find the fail i have maid.

I simply post the necessary codelines in hope that someone can put away the wood infront of my head.


Inside a modal dialogue, these are the calls
C++
for (int y=0;y<5;y++)
{
Schadensnummer[y]=KlendautKlendaut_Gegner[0].Basistrefferermittlung();                               
}



The class "KlendautKlendaut_Gegner0" - function Basistrefferermittlung:
C++
int CBasis::Basistrefferermittlung()
{
    int Zufallstreffer;
    Zufallstreffer=rand()%99+1;
    int Trefferchance;
    Trefferchance=rand()%99+1;
    static int Einschlagsnummer;

    if (Trefferchance>80)
    {
        if (Zufallstreffer>95)
        {
        if (m_Bodyguard>1)
        {
        Einschlagsnummer=20;
        m_Bodyguard=m_Bodyguard-1;
        return (Einschlagsnummer);
        }
        else if (m_Bodyguard<1&&m_Palast>1)
        {
        Einschlagsnummer=21;
        m_Palast=m_Palast-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>90&&Zufallstreffer<95)
        {
            if (m_Fabrik>1)
        {
        Einschlagsnummer=16;
        m_Fabrik=m_Fabrik-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>85&&Zufallstreffer<90)
        {
        if (m_Scanner>1)
        {
        Einschlagsnummer=17;
        m_Scanner=m_Scanner-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>80&&Zufallstreffer<85)
        {
        if (m_Kraftwerk>1)
        {
        Einschlagsnummer=18;
        m_Kraftwerk=m_Kraftwerk-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>75&&Zufallstreffer<80)
        {
        if (m_Zentrale>1)
        {
        Einschlagsnummer=19;
        m_Zentrale=m_Zentrale-1;
        return (Einschlagsnummer);
        }
        }

    }
    if (m_Schutzwall>1)
    {
        Einschlagsnummer=1;
        m_Schutzwall=m_Schutzwall-1;
        return (Einschlagsnummer);
    }
    else if (m_Gefechtsstand>1)
    {
        Einschlagsnummer=2;
        m_Gefechtsstand=m_Gefechtsstand-1;
        return (Einschlagsnummer);
    }
    else if (m_Geschuetzturm>1)
    {
        Einschlagsnummer=3;
        m_Geschuetzturm=m_Geschuetzturm-1;
        return (Einschlagsnummer);
    }
    else if (m_Drohnen>1)
    {
        Einschlagsnummer=4;
        m_Drohnen=m_Drohnen-1;
        return (Einschlagsnummer);
    }
    else if (m_Marines>1)
    {
        Einschlagsnummer=5;
        m_Marines=m_Marines-1;
        return (Einschlagsnummer);
    }
    else if (m_Werkspolizei>1)
    {
        Einschlagsnummer=6;
        m_Werkspolizei=m_Werkspolizei-1;
        return (Einschlagsnummer);
    }
    else if (m_Unterkunft>1)
    {
        Einschlagsnummer=7;
        m_Unterkunft=m_Unterkunft-1;
        return (Einschlagsnummer);
    }
    else if (m_ErhZentrum>1)
    {
        Einschlagsnummer=8;
        m_ErhZentrum=m_ErhZentrum-1;
        return (Einschlagsnummer);
    }
    else if (m_EinkZentrum>1)
    {
        Einschlagsnummer=9;
        m_EinkZentrum=m_EinkZentrum-1;
        return (Einschlagsnummer);
    }
    else if (m_Bunker>1)
    {
        Einschlagsnummer=10;
        m_Bunker=m_Bunker-1;
        return (Einschlagsnummer);
    }
    else if (m_Lager>1)
    {
        Einschlagsnummer=11;
        m_Lager=m_Lager-1;
        m_Lagerpunkte=m_Lagerpunkte-150;
        return (Einschlagsnummer);
    }
    else if (m_Forschung>1)
    {
        Einschlagsnummer=12;
        m_Forschung=m_Forschung-1;
        return (Einschlagsnummer);
    }
    else if (m_MedZentrum>1)
    {
        Einschlagsnummer=13;
        m_MedZentrum=m_MedZentrum-1;
        return (Einschlagsnummer);
    }
    else if (m_Schild>1)
    {
        Einschlagsnummer=14;
        m_Schild=m_Schild-1;
        return (Einschlagsnummer);
    }
    else if (m_Firewall>1)
    {
        Einschlagsnummer=15;
        m_Firewall=m_Firewall-1;
        return (Einschlagsnummer);
    }
    else if (m_Fabrik>1)
    {
        Einschlagsnummer=16;
        m_Fabrik=m_Fabrik-1;
        return (Einschlagsnummer);
    }
    else if (m_Scanner>1)
    {
        Einschlagsnummer=17;
        m_Scanner=m_Scanner-1;
        return (Einschlagsnummer);
    }
    else if (m_Kraftwerk>1)
    {
        Einschlagsnummer=18;
        m_Kraftwerk=m_Kraftwerk-1;
        return (Einschlagsnummer);
    }
    else if (m_Zentrale>1)
    {
        Einschlagsnummer=19;
        m_Zentrale=m_Zentrale-1;
        return (Einschlagsnummer);
    }
    else if (m_Bodyguard>1)
    {
        Einschlagsnummer=20;
        m_Bodyguard=m_Bodyguard-1;
        return (Einschlagsnummer);
    }
    else if (m_Palast>1)
    {
        Einschlagsnummer=21;
        m_Palast=m_Palast-1;
        return (Einschlagsnummer);
    };
}




The array of Schadensnummer[5] always return 1 (Einschlagsnummer==1) out of Basistrefferermittlung. But the class KlendautKlendaut_Gegner[0].m_Schutzwall ist declared only 1 at this point and it is reduced in Basistrefferermittlung. So in the second call of this function it must be 0 and so the Schadensnummer[1] has to be 2. But it stays 1 for every instance of Schadensnummer[].

Does someone has a suggestion?
AnswerRe: Error in returning array of int as reference Pin
Graham Breach22-Oct-16 21:46
Graham Breach22-Oct-16 21:46 
GeneralRe: Error in returning array of int as reference Pin
Korowai22-Oct-16 22:41
Korowai22-Oct-16 22:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.