News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

code::blocks

Started by Roads, September 24, 2012, 03:51:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Roads

I'm about to download code::blocks so I can get started with a c++ tutorial.  Any advice on setup.exe or mingw-setup.exe?


Modify:  Nevermind, sorry for the post; downloaded
Dev C++

prissi

Not sure that this is the most easy way to start. If you use windows, MSVC C++ 2010 may be even easier.

Ters

Is Dev C++ still around? Last I heard of it, it seemed dead and rotting.

Personally, I use code::blocks when I really need an IDE for C/C++, though it's not the greatest piece of software by a long shot. I had mingw set up manually long before I started using code::blocks. From way back when I programmed in Notepad. (Actually, way back then, I used DJGPP, but that's also GCC.)

However, I have never seen a C/C++ IDE as good as the major Java IDEs. And though some of them try to support C/C++ also, they can't seem to pull it off. Microsoft Visual C++ does at least seem solid, but I guess it's something about C/C++ that makes IDEs complicated.

Roads

It has been so long did I did any of this stuff ... and I never worked with anything as low level as C, I'm a total newbie.  I'm going to start with "hello world" because I think I need a solid footing.  First thing I did was download MSVC C++ 2010 and it wouldn't even compile "hello world."

I'll switch to MSVC C++ 2010 when I get a little understanding of the most basic stuff...I mean pointers and arrays and such.  Any help along the way will be greatly appreciated.  Right now I just want to get to the point where I can take care of the little sign addon as changes to the game are made.  I realize I should not be depending on y'all to do stuff like that.  Also I think it would be really great to expand that capability a bit, maybe offer one that lights up at night for cinemas and such.

Markohs

 For Windows users Microsoft Visual Studio 2010 express is the best option in my oppinion.

http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products

Another option is installing mingw:

http://mingw.org/

Or even better, Instal VMWare/VirtualBox and inside there just install a ubuntu and use GCC/Makefile. You can also consider Clang, if you have problems with GPL licenses, as it's usual nowadays sicne last versions are super-restrictive.

http://clang.llvm.org/

I've tried Code::blocks in linux and found it horrible, but that's just my personal opinion.

Roads

Wow!  Thank you.

This is a lot and I'll read and I'll study it all.  Up until 2-3 days ago my thinking had been to finish a game (I still haven't gotten past 1960), and then concentrate on the graphic and code work I want to do.  I've had a new thought.  It is not the destination in this case that matters.  It is the journey.  With that in mind, I'm no longer going to worry about finishing a game, I'm going to approach this the way I like to do things.  That is, play, study, whatever I want for the day or time, then do something else and let whatever I've been doing "soak" in.  It seems when I do this and come back to it, I have a much better view and understanding of it.

yorkeiser

I don't continuously use c and c++ at work by 3 or 4 years, but until then (2009 I think) I found Code::Blocks the best solution for c/c++ programming IDEs.
I actually use (and used) MS visual studio since 2005 version (always professional editions), and yes, it's a good IDE, but only to code in .NET specific languages imho: I found lacking support for c e and its OO counterpart.
Get rid of Dev c++, it's horrible, buggy and lacking support, its developers still are in debt with me for many missed sleep hours... Also some years ago I seem to remember the project to be died, I don't know if it's reborn, but I wouldn't trust however

Roads

yorkeiser,

I will certainly take your advice and get rid of Dev C++ but not just yet.  I spent probably 30 mins last night trying to figure out why my little program wouldn't compile and I had put a semi colon after the #define statement.  So I'm not even taking baby steps yet, I'm still crawling.  I need some practice with the assignment statements and basic stuff like that.  Dev C++ is very simple to use and should be okay for doing that sort of thing.

Markohs

#8
Yea, take into account #define is a preprocessor directive, that just defines a literal to be substituted with something BEFORE compiling in the whole program. Thus if you are using the defined macro in your program you have to mind the macro will just be substituted, and might need a semicolon depending on wthat you are doing:

This two examples will compile even the first one is preferrable because it's cleaner, the second example will compile but it's considered bad quality code most of the times.


#define ZERO 0

int i = ZERO;



#define ZERO 0;

int i = ZERO


The result of the preprocessing (in both cases) will be:

int i = 0;


This is invalid because it misses a semicolon:


#define ZERO 0

int i = ZERO



The result of the preprocessing will be:

int i = 0


Why is the first example preferable? Because it allows you to write something like that:


#define ZERO 0
#define TEN 10

int i = ZERO + TEN + 7;
int z = ZERO;
int t = TEN;




The result of the preprocessing will be:

int i= 0 + 10 + 7;
int z = 0;
int t = 10;

Roads

Yes Markohs, I understand and thank you.

The only thing I didn't get at first about the #define concept was why have it?  You could just assign those values.  Then it occurred to me if you have several functions, the #define would prevent you from having to make those assignments in every function.  Is this right?

Ters

The whole preprocossesor thing allows metaprogramming that opens up a whole bag of neat and hurtful tricks.

You can also put #define ZERO 0 in a header file that is included in multiple source files, but if you put int zero = 0; in such a header file, you get a multiple definition error during linking as there now are multiple variables with the same name zero. There have been other and arguably better solutions over time for giving constants a global name, but the define-way is still around for backward compatibility and for use with preprocessor metaprogramming (at which point int zero = 0; hasn't been evaluated yet).

A thing to remember is that, all things starting with # is in essence just a lot of copy-paste and search-replace stuff done on the source code before compilation. Though closely associated with C/C++, you can in principle use the preprocessor for any language, from plain text and HTML to assembly code if you invoke it explicitly.

Markohs

 Yea, all the macro processing is one of the things that make C/C++ specially tricky to program, most of modern languages don't have it, and it's better that way.

One of the main useful things in preprocessor defines is defining constants that MIGHT change in future compilations of the program if the programmer decides so. For example you could define MAX_PLAYERS as the number of players your game supports, and define for example an array that stores each player's money:


#define MAX_PLAYERS 8

int player_money[MAX_PLAYERS];

unsigned int bankrupt_players(){
   unsigned int n = 0;

   for (i=0;i<MAX_PLAYERS;i++){
       if (player_money[i]<0)
           n++;
   }

   return n;
}



If in the future you decide you will support up to 16 players for example, you just need to change the #define to 16 and re-compile the program. Since you used MAX_PLAYERS everywere you were sizing data structures of even the for loop, the re-compiled program will be correct.

Using #ifdef, #else, #endif we can also write different code that will be compiled or no depending if some vaiables are defined or not. This allows to write parts of the code that deal with UNIX specific I/O functions, or Win32 functions, and compiling one of another using the macro defining tools in compiler (in gcc it's gcc -DMACRONAME, for example).

it's also useful to avoid including a .h file multiple times, you'll see simutrans files starting like:


#ifndef __CITYCAR_READER_H
#define __CITYCAR_READER_H

...
#endif


If you have simutrans sourcecode at hand, for example you can see karte.cc ("karte" means "map" in german I think, and "welt" "world"). karte.cc implements the map drawing functions in the minimap.

On that file you can see:


// Kenfarben fuer die Karte
#define STRASSE_KENN      (208)
#define SCHIENE_KENN      (185)
#define CHANNEL_KENN      (147)
#define MONORAIL_KENN      (155)
#define RUNWAY_KENN      (28)
#define POWERLINE_KENN      (55)
#define HALT_KENN         COL_RED
#define BUILDING_KENN      COL_GREY3


See? That's where we define the colors wich roads, stops, buildings... will be drawn as in simutrans map. If we want to change their color, we whould just need to alter those defines and re-compile. We could make that colors dinamic, allowing to change that value during program execution, but looks like now it's just static, hard-coded into the program.

So, to make it short, macros are meant to make you able to change some parts of the code that will get hardcoded once the compilation ends. It's all static after the compilation ends, since it's only interpreted  before the program gets compiled, and code is generated.

Markohs

#12
 And by the way, it's a common rule, and followed by almost all C/C++ programmers that macros names are allways written is caps, to distinguish them easily from normal variables.

But nothing is forcing you to do it, you can define a macro name in lowercase.

EDIT: Just read what Ters said and yea, it's like copy-paste. ;)

Ters

For stuff like MAX_PLAYER, const int MAX_PLAYER = 8; is the newer and typesafe version of #define MAX_PLAYER 8. But the different nature of those two means that they are not directly interchangeable. When you write const int MAX_PLAYER, MAX_PLAYER is destined to become a part of the final executable, while a #define disappears during compilation leaving only the number behind in its stead.

However, since having the number directly in the code can be faster than getting it from a variable/constant in memory, modern compilers will sometimes/often replace references to the constant with its value sort of like with define, just at later stage (and with proper scoping rules for C++).

Since this feature is "only" about 20 years old (I think, perhaps even a bit less), older code and code written for old systems don't use it. And old habits (and tutorials and example code) die hard.

prissi

const int bla=8; may create warnings when you want to assign it to an unsigned or char. The would not happen with enums or #defines. On the other hand, such error checking by the compiler is handy.

Actually, it should be "static const int" but this did not work in some compilers in h-files. But I think nowadays all fine with this too.

Ters

The confusing thing is that static const int means different thing depending on where you write it. More specifically, it's the meaning of static that is different, and the two meanings are in a sense opposites, as one enlargens the scope in a sense, thile the other restricts it.

TurfIt

On the topic of Code::Blocks  -setup.exe would be best as mingw-setup.exe has a rather old MinGW included. Best to just get MinGW separately.
The 10.05 version works fine, but is missing some things from the newer nightly releases. However they are terribly buggy - need to know enough to know when it's lying to you and give it a swift kick in the ...

MSVC might be simpler for some, but hard to beat Code::Blocks and MinGW for a completely free, totally portable setup that doesn't mess with your OS install.
Dev C++ lasted < 5mins here. Can't remember why, but it must've been rather bad to toss it that quick.


prissi

dev c++ is easy to install al libaries but refuse to work with the current makefile, last time I tested.

Markohs

#18
but, if you put define a "static const int zero = 0" in a .h and include that .h from different .cc files... Will the compiler generate one entry in the data area for each compiled object (.o) that included the .h? Might the linker resolve this and merge all those const variables in just one int?

EDIT: Thinking about this... ofc it will generate one entry in data for each .cc, even it can optimize it further and just replace the ocurrences by the value itself everywere in the .cc. And I pretty much doubt the linker whould do anything like I menctioned.

I like this definition more than macros.

Markohs

btw, found this interesting, from here

stackoverflow.com has to be one of the last useful techincal pages in the web, found lots of useful stuff there, about system administration and programming.

"
One thing worth pointing out, is that the following declaration:
const int i1 = 0;
is exactly the same as static const int i = 0.  A variable in a namespace declared with const and not explicitly declared with extern is implicitly static.  If you think about this, it was the intention of the C++ committee to allow const variables to be declared in header files without always needing the static keyword to avoid breaking the ODR.
"

Roads

#20
First:  Thank you all!

There is so much here I doubt I can even get close to addressing it all.  That said I'm going to try and absorb it little by little.  Markohs, I copied and pasted your program:

#define MAX_PLAYERS 8

int player_money[MAX_PLAYERS];

unsigned int bankrupt_players(){
   unsigned int n = 0;

   for (i=0;i<MAX_PLAYERS;i++){
       if (player_money[i]<0)
           n++;
   }
   return n;
}



into my compiler and got a couple of errors.  It is likely a compiler problem as y'all did say Dev C++ is crap.  Anyway I got rid of one of the errors by assigning the value i = 0.  The other error is for this "for (i=0;i<MAX_PLAYERS;i++)" and the error is

[linker error] undefined reference to WinMain

This I have no idea why since it looks like to me you've created an array with 8 elements and using that in a "for" statement...
Wondering if I'm even in the ball park on this.


Modify:


Ters, here is the program as I have put it in my compiler:
I can't see why this will not compile:




#include <iostream>


using namespace std;


#define MAX_PLAYERS 8


int player_money[MAX_PLAYERS];


unsigned int bankrupt_players()
{
   unsigned int n = 0;
   unsigned int i = 0;
   
   for (i=0;i<MAX_PLAYERS;i++)
   {
       if (player_money[i]<0)
           n++;
   }
   return n;
}

Ters

Markohs code isn't a full program, hence you can't compile just what he wrote into a runable EXE. It's enough for a DLL, though, but those can't be run directly. Markohs also forgot to declare i as an int. It should be for (int i=0;i<MAX_PLAYERS;i++){. (Older code, or code that needs to know at which i the loop terminated, would put int i; outside the for-loop.) I guess the purpose was to demostrate the #define, so the rest was not as important.

Roads

#22
Okay, it is running:




#include <iostream>


using namespace std;


#define MAX_PLAYERS 8


int player_money[MAX_PLAYERS];
unsigned int bankrupt_players;


int main()


{
   unsigned int n = 0;
   unsigned int i = 0;
   
   for (i=0;i<MAX_PLAYERS;i++)
   {
        if (player_money[i]<0)
             n++;
   }
   return n;
}



I'm guessing what Dev C++ didn't like was either not having a function "main" or didn't like the name "bankrupt_players" as a function name although why that would be is beyond me.


Yes Ters, I realize Markohs was only showing a demonstration.  It was new code to me though and looked like it would run so I thought why not play with it using "cout" and kinda get a feel for it.  I'm guessing arrays are used extensively...


Markohs, many thanks for all this info.  I don't have the source code to the game yet.  I had seen the word "karte" before and had no idea what it meant.  My youngest son reads German very well though so I'll get him to help me once I get to that.

Markohs

as ters pointed out the exaple just included one function, all C/C++ programs are suposed to include a "main" routine that's the one that the operating system will execute when the program it's run, once you exit the main(), the program will end, usually.

about the "i" variable, as ters pointed again, I forgot to declare it.

So it's better to write:


for (unsigned int i = 0 ; i<MAX ; i++){
...
}


than:


unsigned int i=0;
for (i=0;i<MAX;i++){
...
}


Makes more sense to declare inside the loop since I won't need the variable "i" outside the "for" loop, allways try to limit variables to the smallest scope possible, to not over-populate the global namestace (the global variables, that are in most of the cases a bad idea to use and should be minimised.  That example assigns 0 to the variable i twice, too, when just one was needed.

You can see what can possibly happen here:


void test (){
    unsigned int i=0;
    unsigned int j=0;

    for (i=0;i<MAX;i++){
        printf("Hi, I'm at position %u\n",i);
    }

    for (j=0;i<MAX;j++){
        printf("Hi, I'm at position %u\n",j);
    }
}


There is something I did intentionally write wrong on that code that whoudn't happen if you'd have declared the variables in the scope of the for, and not at function level. Can you find it? maybe I amde more than one mistake accidentally too hehe. :)

I didn't compiled the code, I just wrote the algorithm without testing, so I might have done some errors.

If you want to practise, you can extend that code to:

1) Print each player's money and how much of them are bankrupt (have <0 money)
2) add/remove a random amount of money from all players
..

There are lots of things you can do to practise. To print values you need the "printf" function, with will require you to add "#include <stdio>", and to get random values you can use this

Ters

(I wrote this before Markohs posted, so some things get repeated, but also more elaborated.)

Quote from: Roads on September 27, 2012, 05:41:07 AM
I'm guessing what Dev C++ didn't like was either not having a function "main" or didn't like the name "bankrupt_players" as a function name although why that would be is beyond me.

main() is the start of a program (console program on Windows). WinMain() is the start of a Windows GUI program. Without either, you don't have a program. I should perhaps have made that more clear in my previous post. Since you told Dev C++ to compile a (GUI) program, it failed when it couldn't find WinMain() (or main()).

Further more, what you return from main() (which must be an int) should by convention be 0 for success, and anything else if something went wrong. So the program in your last post will report back that it "failed" if there are bankrupt players, which may of may not make sense.

Markohs

 Refined it a bit, now it compiles no problem, tested in visual studio


#include <stdio.h>
#define MAX 300

void test (){
    unsigned int i=0;
    unsigned int j=0;

    for (i=0;i<MAX;i++){
        printf("Hi, I'm at position %u\n",i);
    }

    for (j=0;i<MAX;j++){
        printf("Hi! I'm the second loop, I'm at position %u\n",j);
    }
}

int main(){
   test();
}



Roads

I figured using caps was the convention for constants declared with #define.  It seems you are calling them macros or maybe I'm just not understanding.

Sometime I'll ask why the colors are a number and one I see is COL_RED.  I was under the impression for some reason that colors had to be in hex or base 16, however it should be stated, not sure.

Thanks for explaining that about declaring variables only where they will be used.  Something I programmed in years ago, not sure now if it was FoxPro or Oracle, but it seems now like all variables had to be "initialized" before they could be used and I got into the habit of declaring all those at the beginning of the program.  This actually makes it a lot easier because sometimes those programs would get pretty big and you could spend some time chasing down missing variable names or conflicts.

In your code where you asked if I could find what you did intentionally wrong, the only thing I could find was you didn't #define MAX.  And of course I had to change the function name to main. :)
OOPS, nope, here is the problem you are talking about I bet: "(j=0;i<MAX;j++)"
I didn't find it until I changed the code to "(unsigned int j=0;j<MAX;j++)"

I haven't practised any of this yet but will do so now.  Just wanted to post and say all your help and Ters' help is awesome.

Markohs

#27
Quote from: Roads on September 27, 2012, 08:24:20 PM
I figured using caps was the convention for constants declared with #define.  It seems you are calling them macros or maybe I'm just not understanding.

Macros and #define constants are the same thing. The C/C++ preprocessor is just a macro language.

Quote from: Roads on September 27, 2012, 08:24:20 PM
Sometime I'll ask why the colors are a number and one I see is COL_RED.  I was under the impression for some reason that colors had to be in hex or base 16, however it should be stated, not sure.

any number expressed in digits in C is by default in decimal notation. if it starts with 0, it's octal, and beggining in 0x , hexadecimal. It's a number after all, you can input it in any format to C.

http://www.cplusplus.com/doc/hex/

Atm simutrans represents a pixel as a 16 bit integer number, color and graphs are managed in simgraph16.cc .  it's represented in bits as 5 bits red, 5 bits green and 5 blue (I say this from the top of my head, might be wrong in some details). So that 16-bit number just represents a color.

COL_RED is a macro/#define that must be in some other part of simutrans includes.

Quote from: Roads on September 27, 2012, 08:24:20 PM
Thanks for explaining that about declaring variables only where they will be used.  Something I programmed in years ago, not sure now if it was FoxPro or Oracle, but it seems now like all variables had to be "initialized" before they could be used and I got into the habit of declaring all those at the beginning of the program.  This actually makes it a lot easier because sometimes those programs would get pretty big and you could spend some time chasing down missing variable names or conflicts.

In your code where you asked if I could find what you did intentionally wrong, the only thing I could find was you didn't #define MAX.  And of course I had to change the function name to main. :)
OOPS, nope, here is the problem you are talking about I bet: "(j=0;i<MAX;j++)"
I didn't find it until I changed the code to "(unsigned int j=0;j<MAX;j++)"

That's right! :) The thing is, when you reduce the scope, it's easier to catch those errors, with the solution you post, the compiler will complain and in that case with an error, not just a warning. In my version compiler won't complain at all, and that can prolly end in a bug that's undetected for lots of time, since maybe that second "for" loop is just important in some reduced cases, and the crash only shows from time to time, a hard to track down bug.

Ters

Quote from: Markohs on September 27, 2012, 10:55:21 PM
any number expressed in digits in C is by default in decimal notation. if it starts with 0, it's octal, and beggining in 0x , hexadecimal. It's a number after all, you can input it in any format to C.
In the end, they'll all end up as binary numbers anyway.

Quote from: Markohs on September 27, 2012, 10:55:21 PM
Atm simutrans represents a pixel as a 16 bit integer number, color and graphs are managed in simgraph16.cc .  it's represented in bits as 5 bits red, 5 bits green and 5 blue (I say this from the top of my head, might be wrong in some details). So that 16-bit number just represents a color.
On some platforms, it's 5 bits red, 6 bits green and 5 bits blue, which is why there is a function in simsys*.cc to convert from invididual R, G, B values to packed 16-bit color value.

The concept of indexed colors also exist in Simutrans, where one does not specify the color value directly, but as an index into a table with the actual colors. This is typically associated with 8-bit graphics, but Simutrans kind of uses it for player colors and color change due day-night cycle.

Roads

#29
TurfIt,

I'm planning on installing Code::Blocks and MingGW the way you suggested.  That sounds like a good solution for now...maybe go to MSVC 2010 later as I was really put off by the lack of info/support for beginners.  All I got after I installed it was a bunch of screens that led no where.

Markohs,

Just an update...I'm working on the program to print out player money, the number bankrupt, etc.  I've got an idea how to do it but will probably discard it as generally my first idea on how to program something is never the best one.  I could sure use a command reference for syntax on things such as the "if" statement.  The cplus tutorial site either doesn't have it or I've over looked it.


Modify:  Here's my program.  It runs but several problems including the data looks incorrect to me on printout.  I'm just guessing what %u means I thought modulo was just a remainder...  also, rand() is giving the same number every time the program runs.
Also guessed at the usage of "if.[size=78%]"[/size]





#include <iostream>
using namespace std;


#define MAX 8


int main ()
{
    unsigned x = 0;


    for (unsigned int i=0;i<MAX;i++){
        int player_money = rand();
        int luck = rand();
        int account_balance = (player_money - luck);
        printf("player %u\n",i);
        printf("player money %u\n",player_money);
        printf("luck %u\n",luck);
        printf("Account Balance %u\n",account_balance);
        if (account_balance < 0) x++;
    }
    if (x > 0) printf("The number of bankrupt players are %u\n",x);
    return 0;
}

Markohs

This looks like a good place to start reading:

http://www.cplusplus.com/doc/tutorial/

About the %u, inside a printf it's just to tell printf wich format is the parameter you are passing next, and %u means "unsigned int", and %i means "signed int", %s means it's a string. The usage of printf is a bit tricky itself, takes time to undestand at first. here you can find more info..

About the code I'd rearrange it a bit, take this template and try read and finish it. :)


#include <iostream>
using namespace std;


#define MAX_PLAYERS 8
#define STARTING_MONEY 200000;
#define ALTER_ITERATIONS 10;

int player_money[MAX_PLAYERS];

unsigned int get_num_bankrupt_players(){
    unsigned int result = 0;

    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        if (player_money[i] <0 ){
            result++;
        }
    }
    return result;
}

void print_player_money(){
    printf("Account balances:\n");
    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        printf("Player %u has %i SimDollars\n",i,player_money[i]);
    }
    printf ("Number of bankrupt players: %u\n",get_num_bankrupt_players());
}

void reset_player_money(){

    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        player_money[i] = STARTING_MONEY;
    }
}

void alter_player_money(){
    // to be written...
}

int main ()
{

    printf("Starting up...\n");
    printf("Showing players money...\n");
    print_player_money();
    printf("Resetting all players money\n");
    reset_player_money();
    printf("Altering players money...\n");
    alter_player_money();
    printf("Showing players money...\n");
    print_player_money();
}


Markohs

just noted all the examples in that tutorials are done with cout instead of printf, change all printf's to couts if you feel like programming with cout is easier to you, the idea is practising the language. :)

Roads

Using printf is fine.  I've figured out I can use google and find the command I need...


Here's the program.  I doubt it is what you were looking for but it works so maybe it is okay.



#include <iostream>
using namespace std;




#define MAX_PLAYERS 8
#define STARTING_MONEY 200000;
#define ALTER_ITERATIONS 10;


int player_money[MAX_PLAYERS];


unsigned int get_num_bankrupt_players(){
    unsigned int result = 0;


    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        if (player_money[i] <0 ){
            result++;
        }
    }
    return result;
}


void print_player_money(){
    printf("Account balances:\n");
    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        printf("Player %u has %i SimDollars\n",i,player_money[i]);
    }
    printf ("Number of bankrupt players: %u\n",get_num_bankrupt_players());
}


void reset_player_money(){


    for (unsigned int i = 0 ; i < MAX_PLAYERS ; i++ ){
        player_money[i] = STARTING_MONEY;
        // inserting code - Roads
        printf("Player %u has %i SimDollars\n",i,player_money[i]);
        // end insert - Roads
    }
}


void alter_player_money(){
    // to be written...
    // inserting code - Roads
    signed int changed_money;
    int luck;
    for (unsigned int i = 0; i < MAX_PLAYERS; i++){
        changed_money = rand() + 200000;
        luck = rand() % 10;
        if (luck <= 6){
           player_money[i] = (player_money[i]) - changed_money;
           printf("player %u has lost %i SimDollars\n",i,changed_money);
           }
        else{
             player_money[i] = (player_money[i]) + changed_money;
             printf("Player %u has gained %i SimDollars\n",i,changed_money);
        }
        }
        // end of insert - Roads
}


int main ()
{


    printf("Starting up...\n");
    printf("Showing players money...\n");
    print_player_money();
    printf("Resetting all players money\n");
    reset_player_money();
    printf("Altering players money...\n");
    alter_player_money();
    printf("Showing players money...\n");
    print_player_money();
}

Markohs

good enough, in my oppinion. :)

Roads

Okay! :)

Many thanks for all your help Markohs.  I'll continue on with the tutorial at cplusplus and there's another site...