Page 2 of 6 FirstFirst 1234 ... LastLast
Showing results 21 to 40 of 106

Thread: C++ Questions

  1. #21
    Senior Member
    Retired Staff Member

    Saint
    llafnwod's Avatar
    Join Date
    Jul 2004
    Posts
    6,026

    Default

    Quote Originally Posted by Uniquely_Defined
    laffnwod
    llaffanwood
    llafnwood
    laffnwood
    lafwoood
    lanfwod
    lanfwood
    Listen, I dont even care about you spelling my name right anymore, just pick a name and stick with it.
    NEWS YOU CAN USE. IF YOU CHOOSE NOT TO USE THIS NEWS YOU WILL BE KILLED.

  2. #22

    Default

    Quote Originally Posted by llafnwod
    Listen, I dont even care about you spelling my name right anymore, just pick a name and stick with it.
    Hmmm. So many options...Give me a minute to edit once I decide.
    EDIT:llafnwod
    Last edited by Uniquely_Defined : 04-08-2005 at 05:43 PM
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  3. #23

    Default

    Hey guys, I have another question, this time about arrays.
    1.When you assign a value to an element would the following be the correct format:
    Code:
    int smilies[20]=100;
    2.Is this how you assign values to the second element of a multidimensional array? ie:
    Code:
    int smilies[20][25]=100;
    3.When you initialize an array and assign a value would you add brackets around the value being assigned? For that matter, when assigning normal values to arrays do they need brackets around them? ie:
    Code:
    int smilies[100]={50}
    Is that correct? Or is:
    Code:
    int smilies[100]=50;
    Thank you once again for your help.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  4. #24
    Senior Member
    Retired Staff Member

    Saint
    llafnwod's Avatar
    Join Date
    Jul 2004
    Posts
    6,026

    Default

    Quote Originally Posted by Uniquely_Defined
    Hey guys, I have another question, this time about arrays.
    1.When you assign a value to an element would the following be the correct format:
    Code:
    int smilies[20]=100;
    2.Is this how you assign values to the second element of a multidimensional array? ie:
    Code:
    int smilies[20][25]=100;
    3.When you initialize an array and assign a value would you add brackets around the value being assigned? For that matter, when assigning normal values to arrays do they need brackets around them? ie:
    Code:
    int smilies[100]={50}
    Is that correct? Or is:
    Code:
    int smilies[100]=50;
    Thank you once again for your help.
    1 & 2: No need for int unless you are declaring the variable.
    3: What are you trying to do in the first case? Declare the array and assign 50 to smilies[0], assign 50 to smilies[100], or assign 50 to all elements of smilies?
    NEWS YOU CAN USE. IF YOU CHOOSE NOT TO USE THIS NEWS YOU WILL BE KILLED.

  5. #25

    Deviant
    A.H's Avatar
    Join Date
    Mar 2005
    Location
    Austrailia
    Posts
    158

    Default

    Ill be really general.
    you only use the ' { } ' when you initialize the array immediately. like so...
    Code:
    something[] = {1,2,3,4,5};    //and viola!
    and this if you're assigning a value to some part of the array

    Code:
    something[5] = 1      //Assigns the value 1 to the sixth place in the array.
    That should clear things up, maybe?
    Cowards die many times before their deaths;
    The valiant never taste of death but once.

  6. #26

    Default

    Quote Originally Posted by Uniquely_Defined
    Hey guys, I have another question, this time about arrays.
    1.When you assign a value to an element would the following be the correct format:
    Code:
    int smilies[20]=100;
    That statement doesn't work because it attempts to declare an int array of length 100, and then attempts to set the value of element [20] to 100. (Remember, counting starts at 0 with arrays)

    You need to do this:

    int smilies[20]; /* declare int array of length 20 */
    smilies[13] = 7; /* set element 13 value to 7 */

    If you try to compile what you wrote, you should get an initialization error.

    2.Is this how you assign values to the second element of a multidimensional array? ie:
    Code:
    int smilies[20][25]=100;
    Yes, but once again you have attempted to declare and initialize your array at the same time, which is a bad idea. It's confusing, because

    int smilies[20][25]

    declares array "smilies" of type int, correct? However, what the [20][25] does is tell the program how much memory to allocate, not initialize their variables. So again, it should say:

    int smilies[20][25];
    smilies[20][25] = 100;

    3.When you initialize an array and assign a value would you add brackets around the value being assigned? For that matter, when assigning normal values to arrays do they need brackets around them? ie:
    Code:
    int smilies[100]={50}
    Is that correct? Or is:
    Code:
    int smilies[100]=50;
    Thank you once again for your help.
    I know C, not C++. But it should be the same.

    int smilies[100] = {50}
    creates an array with 101 elements, and initializes the value [0] to 50. The rest of the elements are set to NULL (well in C, the last element is the character \0). You use this to assign values to the array upon initialization, like A.H. said. For example:
    int smilies[10] = {1, 2, 3, 4}

    You can do it for multidimensional arrays as well. You just do:

    int matrix[2][4] =
    {
    {1, 2, 3, 4}
    {10, 20, 30, 40}
    };

    If you don't use brackets, you can only change one element in the array.


    Also, you may want to keep in mind, or see if it's like this in C++, but in C, array counting starts at 0. However, the last character is always '\0' (NUL). This marks the end of the array. So even though array[20] has 21 elements (0 to 20), it can only store 20 elements because it reserves the last one for NUL.
    Last edited by pariah : 04-08-2005 at 11:01 PM

  7. #27

    Default

    To llafnwod:
    Thank you for the help. Regarding the latter of the questions, A.H and pariah cleared it up. I just wanted a general answer of when to use brackets.

    To A.H:
    Yes, thank you for clearing things up with the brackets. Thank you for your help.

    To pariah:
    Thank you for everything you posted. I won't go over all the details, but I will mention one thing. Thanks for the tip of not initializing and declaring at the same time. Thank you for your help.

    Thank you guys once again for clearing all of my questions up, in thorough detail might I add.
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  8. #28

    Default

    Quote Originally Posted by Uniquely_Defined

    To pariah:
    Thank you for everything you posted. I won't go over all the details, but I will mention one thing. Thanks for the tip of not initializing and declaring at the same time. Thank you for your help.
    Glad I was helpful.

    Just remember that if you want to initialize at the time of declaration you have to use curly braces {}.

  9. #29
    Arbiter Senior Member
    Retired Staff Member

    Blessed
    TheTempest's Avatar
    Join Date
    Apr 2004
    Posts
    2,086

    Default

    Quote Originally Posted by Uniquely_Defined
    Hey mods feel free, since this is stuck, to delete any of my stupid posts "flaming" him.
    Just took care of that As part of my spring cleaning :D

    My signature is back!! Hell YES!

    Click the link, I DEMAND YOU! :-D
    http://www.bwhacks.com/forums/showthread.php?t=24873

  10. #30
    Retired Staff Member

    High Priest

    Join Date
    Mar 2004
    Location
    Marietta, Ga
    Posts
    1,711

    Default

    Quote Originally Posted by pariah
    int smilies[100] = {50}
    creates an array with 101 elements, and initializes the value [0] to 50.
    Wrong. smilies has exactly 100 elements, and all 100 are initialized to 50.

  11. #31
    Mortal
    Join Date
    Apr 2005
    Location
    Western Hemisphere
    Posts
    3

    Default Args

    I think all the questions were answered, except this one (it was but not well enough).
    3. Why do most programs have "int main(int nNumberofArgs, char*pszArgs[])
    It's so that, if you have a program named prgm, you can do this in the command prompt:
    prgm stuff morestuff stuff3

    Something like that.

    Quote Originally Posted by nickolay
    Wrong. smilies has exactly 100 elements, and all 100 are initialized to 50.
    Not in C++, I'm pretty sure. It's 101.
    Last edited by raylu : 04-23-2005 at 06:57 PM Reason: Added response to nickolay
    There are only 10 types of people in the world: those who understand binary and those who don't.

  12. #32
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    Quote Originally Posted by Uniquely_Defined
    1. Why are pointers useful?(*,&)
    The ampersant sign (&) is the address-of operator. It is not exclusive to pointers. For example:
    Code:
    int x = 9;
    printf("The address holding the data of \"x\" is: %p", &x);
    Would display the address that holds the value of x.

    Quote Originally Posted by raylu
    Not in C++, I'm pretty sure. It's 101.
    You are incorrect. It has exactly 100 elements as nickolay stated. They go from 0 to 99, inclusively. All elements are initialized as the value 50.

    Arrays work the same in this regard in every language I've ever programmed in.

  13. #33

    Default

    heres a good example to teach u: using classes, scope resolution, functions, constructors etc... things, im bored and its 3:40 am so here lemme waste some time then sleep :
    Code:
    // Time1.h
    // demonstrating class Time1
     
    #pragma once
     
    #using <mscorlib.dll>
     
    using namespace System;
     
    public __gc class Time1 // gc = garbage collection
    {
    public:
          Time1(); // constructor
          void SetTime( int, int, int ); // set method
          String *ToUniversalString();
          String *ToStandardString();
     
    private:
          int hour; // 0-23
          int minute; // 0-59
          int second; // 0-59
    };  // end class time1
     
     
     
     
     
     
    // Time1.cpp
    // implementing class time1
     
    #include "stdadx.h"
    #include "Time1.h"
     
    // Time1 constructor initializes variables to
    // zero to set default time to midnight
    Time1::Time1()
    {
          SetTime( 0, 0, 0 );
    }
     
    // set new time value in 24 hour format. Perform validity
    // checks on the data, set invalid value to zero
    void Time1::SetTime( int hourvalue, int minutevalue, int second value )
    {
          hour = ( hourvalue >= 0 && hourvalue < 24 ) ? hourvalue : 0;
          minute = ( minutevalue >= 0 && minutevalue < 60 ) ? minutevalue : 0;
       second = ( secondvalue >= 0 && secondvalue < 60 ) ? secondvalue : 0;
    }
     
    // convert time to universal time (24 hour) fromat string
    String *Time1::ToUniversalString()
    {
          return String::Concat( hour.ToString( S"D2" ), S":",
                minute.ToString( S"D2" ), S":", second.ToString( S"D2" ) );
    }
     
    // convert time to standard time(12 hour) format string
    String *Time::ToStandardString()
    {
          return String::Concat(
                ( ( hour == 12 || hour == 0 ) ? 12 : hour % 12 ).ToString(),
                S":", minute.ToString( S"D2" ), S":", second.ToString( S"D2" ),
                S" ", ( hour < 12 ? S"AM" : S"PM" ) );
    }
     
     
     
     
    // Time1Test.cpp
    // demonstrating class time1
     
    #include "stdafx.h"
    #include "Time1.h"
     
    #using <mscorlib.dll>
    #using <system.windows.forms.dll>
     
    using namespace System;
    using namespace System::Windows::Forms;
     
    int _tmain()
    {
          Time1 *time = new Time1(); // calls time1 constructor
          String *output;
     
          // assign string representation of time to output
          output = String::Concat( S"Initial universal time is: ",
                time->ToUniversalString(), S"\nInitial standard time is: ",
                time->ToStandardString() ):
     
          // attempt valid time settings
          time->SetTime( 13, 27, 6 );
     
          // append new string representation of time to output
          output = String::Concat( output,
                S"\n\nUniversal time after SetTime is: ",
                time->ToUniversalString(),
                S"\nStandard time after SetTime is: ",
                time->ToStandardString() );
     
          // attempt invalid settings
          time->SetTime( 99, 99, 99 );
     
          output = String::Concat( output,
                S"\n\nAfter attempting invalid settings: ",
                S"\nUniversal time: ", time->ToUniversalString(),
                S"\nStandard time: ", time->ToStandardString() );
     
    MessgeBox::Show( output, S"Testing class time1" );
     
    return 0;
    } //end _tmain

    edit: i typed all that fresh outta da box, so um, yea i dont think there is any typos but they aint hard 2 point out so, just watch for em hehehe im sleepy goodnite, hope it helps
    if u have any questions feel free to ask, if i dont answer im sure some1 will
    Last edited by TheUnknown : 01-19-2006 at 01:15 AM

  14. #34

    Zealot
    Pwnd's Avatar
    Join Date
    Jun 2005
    Location
    import java.util.*;
    Posts
    788

    Default

    I know this thread is old, but I also have questions:
    Quote Originally Posted by A.H
    Ill be really general.
    you only use the ' { } ' when you initialize the array immediately. like so...
    Code:
    something[] = {1,2,3,4,5};    //and viola!
    and this if you're assigning a value to some part of the array

    Code:
    something[5] = 1      //Assigns the value 1 to the sixth place in the array.
    That should clear things up, maybe?
    So, basically arrays are the same in C++ as Java? I thought they had a difference.

  15. #35
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    Yes
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  16. #36

    Deviant
    kyleshome's Avatar
    Join Date
    Jun 2005
    Location
    in a small mailbox in space some where
    Posts
    59

    Default

    3. Why do most programs have "int main(int nNumberofArgs, char*pszArgs[])
    as we all know, main is called when the program starts.... most programers just use "int main()" but as i have learned, main is the ONLY time u can leave out the args passed to it, the args that ARE passed to it is a int with the number of args passed to the program at start in command line, and the 2nd one is a char* with the args.
    the args are accessed by ver-name[arg number]


    it was some time since i learned this, and i dont know much about c++ anyways, but the 2nd i know is some kind of array, hope this helped

  17. #37
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    Functions do not require arguments. That aspect is not unique to the main() sub-routine.
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  18. #38

    Default

    Hm, old thread, but I also have some questions..

    1. Is it better to stick with C++ or go to C#?

    2. Are there any benefits over C++ by learning Machine Code?

    3. I've heard WriteProcessMemory is for Windows only. If this is true, does this mean you have to learn a Windows version of C++? And, if you want to do something similar on a Mac, does that mean you'l have to learn a Mac version of C++?

    4. Does C++ need ASM to make powerful hacks?

    5. How could you write to a file's ROM using C++ and change something at a certain address? Also, how can you retrieve information about what is at a certain address?

    This last one is sort of off topic but, how could you latch on to a process that is attempting to hide itself? Example: Trying to use a DLL injector, and coming up with an error claiming the window is found but the process is not.

  19. #39
    Senior Member

    Crusader
    Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,618

    Default

    1) C# is better to go with if you just started learning to program. However, if you have previous experience in C++ and you want to still be able to take advantage of the .NET Framework, than C++.NET (aka C++/CLI) is for you. C++.NET also allows you to interoperably use regular C++ code as well, which means access to the legacy Win32 API.

    2) Assembler variations will always be faster and smaller performance wise. Period. However, the high-level benefits of C/C++/C++.NET far outweigh the practical uses of Assembler.

    3) WriteProcessMemory is a function within the Win32 API, and is therefore unavailable on systems that cannot access the Win32 API. This has to do with the target architecture of the Assembler compiler that generated the assembly (binary output). However, I am sure that other system API's have equivalents.

    4) No.

    5) The Win32 provides methods for accessing and writing memory to both the disk, and the systems dynamic memory. Also, C++ makes use of memory pointers.

    There are several ways around Starcraft's OpenProcess protection. SetWindowsHookEx() is the most effective and simple method that works on virtually every 32-bit and 64-bit version of Windows. It is part of the Win32 API.
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

  20. #40

    Default

    What are the advantages of .NET?
    Is the WIN32 APT on all windows operating systems?
    Machine code (Binary) is acually ASM....?
    Can ASM help to make hacks?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Questions about all these hacks.
    By d0pe in forum Starcraft/Brood War
    Replies: 12
    Last Post: 04-02-2005, 09:34 PM
  2. Google Adsense Questions
    By Marine6592 in forum General Chat
    Replies: 4
    Last Post: 04-01-2005, 06:25 AM
  3. Questions about Damnation and inhale
    By Teddy in forum Starcraft/Brood War
    Replies: 13
    Last Post: 12-29-2004, 12:37 PM
  4. Blackllama Questions
    By llafnwod in forum Flame Board
    Replies: 33
    Last Post: 12-05-2004, 03:37 PM
  5. Questions on hacking
    By x2570 in forum Starcraft/Brood War
    Replies: 4
    Last Post: 10-07-2004, 03:47 PM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •