Thread: void & for

Results 1 to 11 of 11
  1. #1
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed

    void & for

    I have this Code
    Code:
    void variables1(){
    	time_t t;
    	time(&t);
    	srand(t);
    	int mine1 = rand() % 9 + 1;
    	int mine2 = rand() % 9 + 1;
    	int mine3 = rand() % 9 + 1;
    	int mine4 = rand() % 9 + 1;
    	int mine5 = rand() % 9 + 1;
    	int mine6 = rand() % 9 + 1;
    	int mine1x = rand() % 9 + 1;
    	int mine2x = rand() % 9 + 1;
    	int mine3x = rand() % 9 + 1;
    	int mine4x = rand() % 9 + 1;
    	int mine5x = rand() % 9 + 1;
    	int mine6x = rand() % 9 + 1;
    	int minemap1[ 10 ] = { 1,2,3,4,5,6,7,8,9,10 };
    	int* minema1 = &minemap1[10];
    	int minemap2[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    	int minemap3[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    	int minemap4[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    	int minemap5[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    	int minemap6[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    	for ( int x = 0; x < 10; ++x){
    	cout << minemap1[x];
    	}
    	cout << endl;
    	for ( int y = 0; y < 10; ++y){
    	cout << minemap2[y];
    	}
    	cout << endl;
    	system("PAUSE");
    	}
    
    	int main(){
    	cout << "-------------------------" << endl;
    	cout << "| Welcome To MineSorter |" << endl;	
    	cout << "-------------------------" << endl;
    	variables1 ();
    	}
    It should cout minemap1 with 12345678910 no?with I jsut get strange letters...

    any help?
    Last edited by alvaritos; 07-21-2011 at 10:07 AM.

  2. #2
    Toxic Waltz's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    114
    Reputation
    14
    Thanks
    18
    please indent the code. it is too difficult to read this way.
    Indent style - Wikipedia, the free encyclopedia

    and try using structs.
    Last edited by Toxic Waltz; 07-21-2011 at 11:14 AM.

  3. #3
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    Code:
    #include <ctime>
    #include <iostream>
    using namespace std;
    	int main(){
    			int minemap2[ 10 ] = { 'A','B','C','D','E','F','G','H','I','J' };
    				for ( int y = 0; y < 10; ++y){
    				cout << minemap2[y];
    				}
    		cout << endl;
    	system("PAUSE");
    	}
    I just don get the letters in the cout.. I get numbers

    OH well My fail mystake... It was "char" no " Int " xD

  4. #4
    Toxic Waltz's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    114
    Reputation
    14
    Thanks
    18
    When indenting, try to line up brackets that belong together.

  5. #5
    Fovea's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    325
    Reputation
    101
    Thanks
    411
    My Mood
    Amused
    As if there is a proper indenting style...

  6. #6
    Toxic Waltz's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    114
    Reputation
    14
    Thanks
    18
    Quote Originally Posted by Fovea View Post
    As if there is a proper indenting style...
    there is a style I like. and because of that it is the bestest

  7. #7
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    it seems like u just copy and paste things u dont understand into 1 big project, and ask here what's wrong with them.
    an array of 10 would start with [0] and end with [9].
    Last edited by kibbles18; 07-21-2011 at 12:24 PM.

  8. #8
    FailHacker's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    444
    Reputation
    8
    Thanks
    49
    system("PAUSE");

    ^^ please please please dont use this

    use cin.get();
    Legen...wait for it...dary







  9. #9
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    ok and , why?
    I will use that

  10. #10
    FailHacker's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    444
    Reputation
    8
    Thanks
    49
    using system("PAUSE") is like burning your furniture for heat when you have a perfectly good thermostat on the wall.


    It's not portable. This works only on systems that have the PAUSE command at the system level, like DOS or Windows. But not Linux and most others...

    It's a very expensive and resource heavy function call. It's like using a bulldozer to open your front door. It works, but the key is cleaner, easier, cheaper. What system() does is:

    suspend your program

    call the operating system

    open an operating system shell (relaunches the O/S in a sub-process)

    the O/S must now find the PAUSE command

    allocate the memory to execute the command

    execute the command and wait for a keystroke

    deallocate the memory

    exit the OS

    resume your program

    There are much cleaner ways included in the language itself that make all this unnessesary.

    You must include a header you probably don't need: stdlib.h or cstdlib

    It's a bad habit you'll have to break eventually anyway.

    Instead, use the functions that are defined natively in C/C++ already. So what is it you're trying to do? Wait for a key to be pressed? Fine -- that's called input. So in C, use getchar() instead. In C++, how about cin.get()? All you have to do is press RETURN and your program continues.
    Legen...wait for it...dary







  11. #11
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Quote Originally Posted by FailHacker View Post
    using system("PAUSE") is like burning your furniture for heat when you have a perfectly good thermostat on the wall.


    It's not portable. This works only on systems that have the PAUSE command at the system level, like DOS or Windows. But not Linux and most others...

    It's a very expensive and resource heavy function call. It's like using a bulldozer to open your front door. It works, but the key is cleaner, easier, cheaper. What system() does is:

    suspend your program

    call the operating system

    open an operating system shell (relaunches the O/S in a sub-process)

    the O/S must now find the PAUSE command

    allocate the memory to execute the command

    execute the command and wait for a keystroke

    deallocate the memory

    exit the OS

    resume your program

    There are much cleaner ways included in the language itself that make all this unnessesary.

    You must include a header you probably don't need: stdlib.h or cstdlib

    It's a bad habit you'll have to break eventually anyway.

    Instead, use the functions that are defined natively in C/C++ already. So what is it you're trying to do? Wait for a key to be pressed? Fine -- that's called input. So in C, use getchar() instead. In C++, how about cin.get()? All you have to do is press RETURN and your program continues.
    Those analogies were epic.

Similar Threads

  1. Idea for dye amp preview program?
    By slayer991133 in forum Vindictus Help
    Replies: 2
    Last Post: 10-27-2011, 11:09 PM
  2. Hacks for mmorpg?
    By suppaman in forum General Game Hacking
    Replies: 6
    Last Post: 10-17-2010, 11:04 AM
  3. cheat for gunz
    By suppaman in forum Gunz General
    Replies: 27
    Last Post: 02-07-2006, 07:34 PM
  4. Looking for hacks
    By Worcha in forum General Game Hacking
    Replies: 0
    Last Post: 12-29-2005, 03:21 PM
  5. Too Ownage For Words.
    By Flawless in forum Art & Graphic Design
    Replies: 8
    Last Post: 12-28-2005, 04:55 PM