Click here to Skip to main content
15,885,278 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Error in returning array of int as reference Pin
Midi_Mick22-Oct-16 23:12
professionalMidi_Mick22-Oct-16 23:12 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 2:39
Korowai23-Oct-16 2:39 
GeneralRe: Error in returning array of int as reference Pin
leon de boer23-Oct-16 4:24
leon de boer23-Oct-16 4:24 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:11
Korowai23-Oct-16 8:11 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:26
Korowai23-Oct-16 8:26 
QuestionRe: Error in returning array of int as reference Pin
David Crow23-Oct-16 15:26
David Crow23-Oct-16 15:26 
AnswerRe: Error in returning array of int as reference Pin
Joe Woodbury24-Oct-16 14:07
professionalJoe Woodbury24-Oct-16 14:07 
QuestionMost efficient way to create a string range in C? Pin
Member 1280348819-Oct-16 10:19
Member 1280348819-Oct-16 10:19 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer19-Oct-16 19:33
leon de boer19-Oct-16 19:33 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer20-Oct-16 21:14
leon de boer20-Oct-16 21:14 
AnswerRe: Most efficient way to create a string range in C? Pin
Joe Woodbury26-Oct-16 12:16
professionalJoe Woodbury26-Oct-16 12:16 
QuestionHow to invoke Printing Preferences for the given Printer programmatically? Pin
purnachandra505016-Oct-16 17:48
purnachandra505016-Oct-16 17:48 
SuggestionRe: How to invoke invoke Printing Preferences for the given Printer programmatically? Pin
Richard MacCutchan17-Oct-16 5:06
mveRichard MacCutchan17-Oct-16 5:06 
QuestionHelp please Memoized rod cutting in C while showing the length it is cut Pin
Member 1279667016-Oct-16 12:03
Member 1279667016-Oct-16 12:03 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
leon de boer16-Oct-16 16:12
leon de boer16-Oct-16 16:12 

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.