I would recommend [url=http://www.bloodshed.net/devcpp.html]Bloodshed Dev-C++[/url] for C++ programming.

If you want to compile C code, I would suggest using a C compiler such as GCC. I'm un-aware of any free available IDE envrionments for the C language. Though you may be able to compile C code in Dev-C++. I've never tried, though.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow


If I understand correctly, you want to replace all space occurances to "[color=green]space[/color]" where [color=green]space[/color] represents the space, ' ', character:[code][color=red]sed[/color] [color=#CC3200]-i[/color] '[color=blue]s/ /[/color][color=green]\ /[/color]' [color=purple][i]file[/i][/color][/code]
To clarify:
[color=red]sed[/color] — Is the program.
[color=#CC3200]-i[/color] — Is a sed option that can edit files in place (makes backup if extension supplied)
[color=blue]s/ /[/color] — Finds all occurances of space
[color=green]\ /[/color] — Replaces the space with '\ '. Without the single quotation marks.
[color=purple][i]file[/i][/color] — Is the input file.

For reference, the [color=blue]s[/color] command is the [i]substitution[/i] command. The [color=blue]/ /[/color] statement is to find any occurance of a space. The [color=green]\ /[/color] statement will replace the space, ' ', found with '\ '.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow


If I understand correctly, you want to find which of the totals are shortest. Like from minimum to maximum, e.g. A is less than B so B is greater; B is greater than C so C is less than B.

Maximum to minimum example:
B [is greater than A and C]
C [is greater than A but less than B]
A [is the least of them all]

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow

Q. Do I use this system?
A. There are some advantages to using this system.

[]Is the person trustworthy
]Do they often give useful information
[*]Are they respected in this community

I do my best to fall under all of those categories, as majority of my posts are informational. The more reputation someone has, the better chance of being heard as valid will increase. Reputation is simply an overall quality seen or judged by people in general. Having esteem is one thing, and detesting or loathing is another.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow
Gary King commented: nice reasoning +2


Glad to be of assistance.

i dont think it recognized #include
I've heard this from alot of programmers before. Though there is a difference between and .

[b][u]Difference between iostream.h and iostream[/u][/b]
[b]iostream[/b] is somewhat more restrictive than the older [b]iostream.h[/b]. One would possibly avoid problems by careful use of namespaces, but it would be a lot smarter to stick with one or the other.

On a futher note, iostream.h is deprecated (it was replaced when the C++ standard came out about 7 years ago)

Technically speaking, iostream.h is not considered depreciated, because it was never part of the official standard in the first place.

You should avoid using the .h version as much as possible, because some implementations have bugs in their .h version. Moreover, some of them support non-standard code that is not portable, and fail to support some of the standard code of the STL.

Furthermore, the *.h version puts everything in the global namespace. The extension-less version is more stable and it's more portable. It also places everything in the std namespace.

iostream.h is an old style method of including std C++ headers, and in opposite to iostream you don't have to declare that you're using the std namespace.

It is sometimes recommended to use:

[color=blue]using namespace[/color] std;[/code]

[b][u]What does using namespace do?[/u][/b]
Explained as simply as possible, namespaces allows us to group a set of global classes, objects and/or functions under a name. If you specify using namespace std ...

StuXYZ commented: Two very well written post, many thanks! +3


Using a 2-Dimensional array isn't very difficult at all. In fact for simplicity, lets take a look how a 2-Dimensional array looks in all aspects.

[code][color=blue]int[/color] myValue[2][3];[/code]

We know this array is going to be a 2x3 rectangle. So lets see how this looks:

[code]Rows/Columns Column 0 Column 1 Column 2 Column 3
Row 0 myValue[0][0] myValue[0][1] myValue[0][2] myValue[0][3]
Row 1 myValue[1][0] myValue[1][1] myValue[1][2] myValue[1][3][/code]

Not bad at all. How about if we initialize this array:

[code][color=blue]int[/color] myValue[2][3] = { {5, -3, 0}, {10, 17, -25} };[/code]

There are two blocks, with 3 numbers inside each initializing our 2x3 array completlely:

[code]Rows/Columns Column 0 Column 1 Column 2
Row 0 5 -3 0
Row 1 10 17 -25[/code]

This should all be making sense. To set your array's data outside of the initilization isn't hard at all:

[code][color=blue]int[/color] main() {
[color=blue]int[/color] myValue[2][3]

myValue[0][0] = 5;
myValue[0][1] = -3;
myValue[0][2] = 0;

myValue[1][0] = 10;
myValue[1][1] = 17;
myValue[1][2] = -25;

[color=blue]return[/color] 0;


So think of a 2-Dimensional array as a rectangle. Rows and Columns, right and down. Once you have this down, please feel free to ask more questions.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow

Greetings chound,

C provides [b]typedef[/b], a facility for creating new data type names. It makes your name a synonym of the defined data-type:

[code][color=blue]typedef int[/color] Number;[/code] The type Number can be used in declarations and casts in exactly the same ways that the defined type [b]int[/b] can be:

[code]Number i, cars;
Number *blocks[];[/code]

Using a synonym for "[color=blue]char[/color] *" is similarily declared. Example:

[code][color=blue]typedef char[/color] *Str;

Str s, a[5], *p;[/code]

The type being declared in a [b]typedef[/b] appears in the position of a variable name, not after the word [b]typedef[/b]. The typdef sytax is like the storage classes [color=blue]extern[/color], [color=blue]static[/color], and many others. The typedef declaration does not create a new data-type of any sense. It's simply stated as it adds a new name for some existing type.

[b]typedef[/b] is similar to [color=blue]#define[/color], expect that it is interpreted by the compiler. There aren't any new semantics. Variables declared this way have exactly the same properties as variables whose declarations are spelled out explicitly.

Hope this helps,

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow


The [b]if-else[/b] statement is normally used to express decisions, where the [b]else[/b] part is usually optional. Since an [b]if[/b] simply tests the numeric value of an expression, coding shortcuts are possible:

[code][color=blue]if[/color] (expression)
[color=#008800]// instead of[/color]
[color=blue]if[/color] (expression != 0)[/code]Example 1.1: Using coding shortcuts

There is an ambiguity when an else is omitted from a nested [b]if[/b] sequence, since the [b]else[/b] part of an [b]if-else[/b] is optional.

[code][color=blue]if[/color] (a < 0)
[color=blue]if[/color] (b < c)
r = b;
r = c;[/code]Example 1.2: Ambiguity between control flow statements

The construction of the [b]if-else[/b] syntax is simple:

[code][color=blue]if[/color] (expression)
statement 1
statement 2[/code]

The [b]else-if[/b] construction is similar, though it evaluates all expressions in order; and if any expression is true, the statement associated with it is executed and terminates the whole chain:

[code][color=blue]if[/color] (expression)
[color=blue]else if[/color] (expression)
[color=blue]else if[/color] (expression)
statement[/code]Example 1.3: Using the Else-If syntax

So to do accomplish your task, you could do something like the following:

[code][color=blue]if[/color] (total >= 80 && total <= 100) [color=#008800]// 80 between 100[/color]
[color=blue]else if[/color] (total >= 50 && total <= 79) [color=#008800]// 50 between 79[/color]
[color=blue]else if[/color] (total >= 45 && total <= 49) [color=#008800]// 45 between 49[/color]
[color=blue]else[/color] [color=#008800]// probably an F grade here[/color]
statement;[/code]Code 1.1: Using if-else in application

If you have multiple statements withing one [b]if[/b], you must group the declarations together into a compund statement using braces ([b]{[/b] [b]}[/b]):

[code][color=blue]if[/color] (expression) { [color=#008800]// multi-computation[/color]
statement 1;
statement 2; ...

Greetings Smarkles,

I put together a small package of the OpenGL DLLs and Header/Library files. You can download them [url=http://www.bluedevstudios.net/?page=downloads]here[/url]. You should find a few links there containing either the DLLs or Header files.

Some good tutorials can be found [url=http://nehe.gamedev.net/lesson.asp?index=01]here[/url] also. If you have further questions, please feel free to ask.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow


Writing your own version of gotoxy() and clrscr() would probably be for the best. They can be found all over the place, but the best ones I've found were:


[color=blue]void[/color] gotoxy([color=blue]short[/color] x, [color=blue]short[/color] y) {
HANDLE hConsoleOutput;
COORD Cursor_Pos = {x, y};

hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, Cursor_Pos);


[color=blue]void[/color] clrscr([color=blue]void[/color]) {
COORD coord = {0, 0};
DWORD count;

GetConsoleScreenBufferInfo(hStdOut, &csbi);
FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
SetConsoleCursorPosition(hStdOut, coord);


Doing the rest is quite simple. Here's a simple layout of how this can be accomplished:

[]Create a function to update the player's position. Have it clear the screen everytime this is called
]Use an infinite while loop and get the key pressed using getch()
[*]Call a switch case and find out which key was pressed and where to update the players position

That should get you to a good start, and good luck.

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow


This process is not hard since the default libraries included a function to do this. It's called itoa().

[b]»[/b] [color=blue]char[/color] itoa([color=blue]int[/color] value, [color=blue]char[/color] buffer, [color=blue]int[/color] radix);
Converts an integer value to a null-terminated string using the specified radix and stores the result in the given buffer.
If [i]radix[/i] is 10 and value is negative the string is preceded by the minus sign (-). With any other [i]radix[/i], value is always considered unsigned.
[i]buffer[/i] should be large enough to contain any possible value: (sizeof(int)*8+1) for radix=2, i.e. 17 bytes in 16-bits platforms and 33 in 32-bits platforms.
Further information can be found [url=http://www.cplusplus.com/ref/cstdlib/itoa.html]here[/url].

Here is an example of how to use this function:
[code][color=blue]#include[/color] [color=#008800]// for itoa() call[/color]
[color=blue]#include[/color] [color=#008800]// for printf() call[/color]

[color=blue]int[/color] main() {
[color=blue]int[/color] num = 123;
[color=blue]char[/color] buf[5];

[color=#008800]// convert 123 to string [buf][/color]
itoa(num, buf, 10);

[color=#008800]// print our string[/color]
printf("%s\n", buf);

[color=blue]return[/color] 0;


I hope this helps,

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow

Greetings Darakuli,

RPG [Role Playing Games] isn't an easy task to undertake, as you may know. It's usually recommended to take a standard game programming course, and to know the C or C++ language effeciently. Taking on the tasks of creating a Tetris clone, Pacman, or Asteroids would be the typical stepping stones before starting on a MMORPG.

Using game libraries such as [url=http://www.libsdl.org/index.php]SDL[/url] or [url=http://www.talula.demon.co.uk/allegro/]Allegro[/url] may help jumpstart you in the right direction.

Also, as some of us are open-source fans, check out [url=http://happypenguin.org]happypengiun.org[/url] as the site is full of games of all types. Also, while you're there, check for map editors. If you don't like what you find, write your own.

[url=http://www.google.com]Google[/url] is also a good place to search when looking for examples, or further detail. A popular 3D RPG game is [b]Crystal Space 3D[/b], if interested. Just do a search for that, and you're on your way.

Out of the question, there is the [url=http://www.verge-rpg.com/]Verge-RPG[/url] engine which uses script familiar to the C language. Later, or latest version(s) may soon be released in C# ([i]C Sharp[/i]). This engine is free.

Another good place for game engines are at [url=http://www.garagegames.com]Garage Games[/url]. You could license the Torque engine, though it's costly. It's roughly $100 per programmer for licensing last I checked.

I hope this information has been useful,

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow

I would recommend [b]getline()[/b] instead of [b]cin >>[/b]:

[code]cin.getline(UsrName, 10, '\n');[/code]

Here's more information about [url=http://www.cplusplus.com/ref/iostream/istream/getline.html]getline()[/url] and its paramaters.

Hope this helps,

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow
Killer_Typo commented: Thanks you very much for that comment, ill definatly look into it! --KT +1


I did see a few errors that evidently caught my attention.

Firstly, on line 6 of your posted code you have the following:

[code][color=blue]int[/color] side1 = 0;[/code]

Though 4 lines later, [or line 10], you state the following:

[code][color=blue]for[/color]( [color=blue]int[/color] side1 = 0; side1 <= 500; side1++ )[/code]

What this is doing is creating an integer called side1, which may cause errors since you already defined an integer of the same name on line 6. The same goes for [b]side2[/b] and [b]hypotenuse[/b]. Since the variable already exists, the for loop shouldn't contain the [color=blue]int[/color] data type.

Also, in your calculation of checking if the [i]two sides equal the hypotenuse[/i] will always pass since asking if a variable [i]equal[/i] or [i]equals[/i] is different. See why:

[code][color=blue]if[/color] (a = b) { b = a; } [color=#008800]// will not ensure a equals b (why, because you are setting a to b not checking for comparing)[/color]
[color=blue]if[/color] (a == b) { b = a; } [color=#008800]// this ensures a equals b using ==[/color][/code]

Likewise with your following statement if this makes sense:

[code]if( ( side1 side1 ) + ( side2 side2 ) [color=red]=[/color] ( hypotenuse * hypotenuse ) )[/code]

Other than that, I haven't tried to compile your code, and do not know where the C2106 error lies within.

I hope this helps,

  • [color=#CC3200]S[/color]tack [color=#CC3200]O[/color]verflow

Hello fellow programmers,

This is a tutorial about using pointers in the C environment. Please, don’t hit the back button; pointers aren’t as hard as you think. In fact without pointers, most of us would be lost in our latter programming years.

Even though pointers are for the experienced, as they say, I’m here to help programmers from consisting of all levels to help greater understand pointers, and why they are pertinent to your everyday programming needs.

Let me start off by stating, a pointer is a variable that contains the address of another variable. Pointers and arrays are closely related, though pointers are sometimes the only way to express a computation. Some also say pointers usually lead to more compact and efficient code. If you view the following example [1.1], it may confuse you or if not, you’ll see the incompleteness of it:

[code][color=blue]int[/color] main() {
[color=blue]char[/color] c;
[color=blue]char[/color] ch[2];
[color=blue]char[/color] *pch;

c = ‘a’;
ch[0] = ‘a’
*pch = ch[0];

[color=blue]return[/color] 0;

}[/code] Example 1.1: An incomplete look at pointers

Pointers and addresses need allocation to store its data. Unlike the char and char[] data types, which use locally stacked memory, pointers pass though existing memory stacks.

The unary operator “&

Dave Sinkula commented: You should still fix 1.4, though. --Dave +1