# applet troubles (wanna try C/C++)

This topic is 3863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

ok, seems like the first thing to do is to get Allegro library. So i did; installed it through my Dev-C++ but it still says that it cant locate allegro.h and its functions. [ramble] Im kinda been programming in Java which is not such a pain in an *** (dont have pointers which as everyone knows are pointless). Wanna know if its worth it to switch to C. I know Java says that its "multiplatform" except people who gonna play yo game will have to download 13MB of virtual machine and other java stuff. I suppose that C creates .exe files instead of .jar or .jnlp which is more portable, so here is one advantage. Plus im having trouble writing files in Java since its so secure . . . But the game that i wanna write will require a 60x2000 array of bytes and since c/c++ is a memory hog, i dont know if its possible. Just wanna know if its worth it since the problems will just keep on piling up and ive solved some while doing games in java. [/ramble] Anyways, need a concise step-by-step tutorial on how to make my compiler recognize Allegro. [Edited by - alexxzius on June 24, 2007 11:38:03 AM]

##### Share on other sites
Quote:
 Original post by alexxziusdont have pointers which as everyone knows are pointless

Are you kidding?

##### Share on other sites
You are startlingly misinformed about... most everything. I know nothing about Allegro, so I won't be much help there, but:

Quote:
 dont have pointers which as everyone knows are pointless

Just because you don't know how to use them doesn't make them pointless. Direct memory access (pointers) is one of the things that makes low-level languages (like C) so powerful and fast. It also makes them more difficult to learn, and more prone to errors. It's an advanced feature, not pointless.

Quote:
 I suppose that C creates .exe files instead of .jar or .jnlp which is more portable

... maybe I misunderstand what you're trying to say here. An executable is about the least portable file format there is, since it's built particularly for a specific piece of hardware. A .jar file is platform-independent, meaning (theoretically) that it is the ultimate portable format: the exact same file should run on any Java-supported hardware with no changes.

Quote:
 But the game that i wanna write will require a 60x2000 array of bytes and since c/c++ is a memory hog, i dont know if its possible.

Huh? Are you confusing the two languages? Java uses a special runtime, which requires extra memory. C/C++ compiles to an executable that does not require a runtime, making C/C++ less of a memory hog.

And a 60x2000 array of bytes is only 117k... an eight of a megabyte, the equivalent of a small (approx 170x170) bitmap image. That's not at all memory intensive.

Good luck with your Allegro setup... like I said, I can't really help there. But you should do a bit less rambling and a bit more fact checking when bitching about language selection. C is a pain in the ass for many reasons, but none of which you listed here.

##### Share on other sites
Quote:
 Original post by alexxzius... But the game that i wanna write will require a 60x2000 array of bytes and since c/c++ is a memory hog, i dont know if its possible...

What? that doesn't make any sence, who told you that, or what do you mean?

##### Share on other sites
Have you add the path to allegro folder?
I don't know anything about allegro, but it seems it is common problem from people starting c++.

##### Share on other sites
I won't rehash what the others have said, but I'll try and help. I found this thread the has a post describing a pretty good step-by-step procedure install allegro on dev-cpp. Hope it helps.

##### Share on other sites
Quote:
 Original post by alexxziusdont have pointers which as everyone knows are pointless

When I first read this I thought you were just trying to be clever. I chuckled, but I'm a sucker for bad puns [lol].

Anyway, if you're at all serious about C++ development, get yourself a decent IDE. Dev-C++ is outdated and no longer being updated. I suggest MS Visual Studio 2005. The express edition is free, and pretty kick-ass in terms of features.

##### Share on other sites
Quote:
Original post by ExcessNeo
Quote:
 Original post by alexxziusdont have pointers which as everyone knows are pointless

Are you kidding?

Serously pointers aren't pointless. You should get to know them before you pre judge they make everything easier and better. Give you more control over memory and allow to do a ton of stuff.

##### Share on other sites
Quote:
 dont have pointers which as everyone knows are pointless

This is far from truth. It can be very difficault to manipulate
a string directly, for example, without pointers.

Memory allocation is impossible without pointers.

Not using pointers (or refrences) when passing objects to routines
can cause dramatic slowness because of its heavy use of the stack.

It is impossible to do almost anything low level without them.
(ie, memory access, assembly, etc...)

File handling is done either directly or indirectly by file pointers.

Im sure other members here can add more to this list[smile]
Quote:
 I suppose that C creates .exe files instead of .jar or .jnlp which is more portable, so here is one advantage.

This is not entirely true. C (and C++) compiliers do not generate
executable files, only object files. For example, Elf, coff, obj, etc..

The Linker generates the executable file. The format might not
even be EXEs. It depends on what platform you are developing for.

Quote:
 But the game that i wanna write will require a 60x2000 array of bytes and since c/c++ is a memory hog

If this was true, I dont think C or C++ would be used in game development.
The only libraries linked into C and C++ are the libraries that you use, and
no more.

Also, if you never use pointers, the array of bytes will be on the stack,
not the heap.

Quote:
 "C/C++" does not really exist.

I type "C/C++" as a force of habit--representing either C or C++; not both[smile]

Hope this helps.

##### Share on other sites
wow that must be a record for one phrase to be quoted and trashed. . .
Ive used pointers before so I know a few things. They may be fast, but only in execution sense. They clog up the program which makes it hard to program.
*(list+indx)->data[0]=5; // make me wonder what the?
I might as well program entirely in assembly to make it even more faster.
Correct me if im wrong but Java dont have pointers and it dont miss it a bit. (except u cant write viruses in Java)

Maybe its wrong for me to assume that C/C++ is a memory hog, but from past experience my programs crashed when i had an array of more than 300 ints.

About portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)
And i seen .exe files in my Dev-C directory without linking anything (if only java could do that . . .)

Ok, i assume that the answer is NO. Fine. Forget C/C++ then.
Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.
...
<applet code=applet1.class archive=applet1.jar width=500 height=300>
...

and it gives me a bunch of Unknown Source errors. Help apreciated. ;)
[[This thread can be found in java development forum. I suppose this forum is more active since i get like 1 responce a week in Java forums.]]

##### Share on other sites
Was the ramble part generated using a Markov chain?

The words are correct, so are short fragments, but they have no context, and they are all absurdly incorrect or make no sense.

##### Share on other sites
that was to warn light-hearted people. Guess it didnt work . . .
If u dont understand a thing i said, forgive my russian potomu chto ya ploho govoryu po angliyski. Mne ochen nuzhna pomosh.

Need to execute my jars.

##### Share on other sites
Quote:
 Original post by alexxziuswow that must be a record for one phrase to be quoted and trashed. . .Ive used pointers before so I know a few things. They may be fast, but only in execution sense. They clog up the program which makes it hard to program. *(list+indx)->data[0]=5; // make me wonder what the?I might as well program entirely in assembly to make it even more faster. Correct me if im wrong but Java dont have pointers and it dont miss it a bit. (except u cant write viruses in Java)

Yes, pointers do make C (and C++) a hard language to learn. Just because they are difficult to comprehend doesn't make them pointless; they're what make C such as an excellent language for low-level programming.

Quote:
 Original post by alexxziusAbout portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)

.jar files can definitely run on a PC. How are you executing them?

Quote:
 Original post by alexxziusOk, i assume that the answer is NO. Fine. Forget C/C++ then.Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.......

This thread might be able to help.

##### Share on other sites
Quote:
 Original post by alexxziusCorrect me if im wrong but Java dont have pointers and it dont miss it a bit

Java does actually have pointers it's just under the hood. everything in java is pass by reference by default which is like passing by pointer. Java doesn't give you direct access to freeing memory but again it does it all under the hood.

Quote:
 Original post by alexxziusMaybe its wrong for me to assume that C/C++ is a memory hog, but from past experience my programs crashed when i had an array of more than 300 ints.

That's because you are allocating the array on the stack instead of the heap. In C you are generally limited to 2MB of stack memory by the OS. In java, arrays are automatically created on the heap. The correct way to allocate a big array in C:

int *myArray = new int[300];//and when you're donedelete[] myArray;

Again under the hood, that's what Java does when you allocate an array.

Quote:
 Original post by alexxziusAbout portability: even after installing every java utility from sun i still cant execute jar files. Maybe jars work on cell-phones, mp3 players and calculators but unless they work on PC's they kinda usless. (Dont quote its just an assumption ;)

Of course you can execute jars on a PC. you just haven't taken the time to read the documentation. The above poster has a link you should read.

Quote:
 Original post by alexxziusAnd i seen .exe files in my Dev-C directory without linking anything (if only java could do that . . .)

The entire purpose of Java is so that it never has to generate an exe. A .exe file is only for windows. It will not run on: *nix, Mac or any other operating system without emulation. .jar runs in a java virtual machine. there are VMs available for almost every platform out there which makes the .jar format extremely powerful because it does not need to be re-compiled to run on another platform. It makes it a little tricky to run (you have to properly set up an execution environment) but that's the tradeoff for portability.

Quote:
 Original post by alexxziusOk, i assume that the answer is NO. Fine. Forget C/C++ then.Since all ya experts in like every language, can u give me some advice on how to make my browser run jar files. I created the jar file, put it next to my .htm page like the tutorial said.... ...and it gives me a bunch of Unknown Source errors. Help apreciated. ;)[[This thread can be found in java development forum. I suppose this forum is more active since i get like 1 responce a week in Java forums.]]

No you didn't. You made a normal jar not an applet. To run java in a browser you need to specifically author an applet, not just a normal java application. How to author an applet:
http://java.sun.com/applets/

You really need to stop thinking that you already know all the answers. You know very little (which is totally fine and completely expected for a beginner). You are crippling your learning process by expecting that everything is simple. Programming is hard and takes a month or so before all the building and running of applications becomes 2nd nature.

-me

##### Share on other sites
thanx for the reply. I had the same problems with running applets (not jars). I solved it by running an apletviewer once which somehow (?) made my browser display applets which it couldnt do before.
The thread didnt help much cause im executing my jars from my hard drive, not from the internet. Guess thats different. And my JRE and JDK are of the same release...

A question: u normally cant run jars just by clicking on them, can u? I did and it gave me an error which said that a binary was missing or something...

##### Share on other sites
Quote:
 Original post by alexxziusA question: u normally cant run jars just by clicking on them, can u? I did and it gave me an error which said that a binary was missing or something...

I think with some Java VMs you can just double-click jars. It may be a configuration issue. It's been a long time since I've programed client-side java so I don't really know for sure.

-me

##### Share on other sites
Quote:
 int *myArray = new int[300];//and when you're donedelete[] myArray;

again pointers. Thats why i switched to java

Quote:
 No you didn't. You made a normal jar not an applet. To run java in a browser you need to specifically author an applet, not just a normal java application. How to author an applet:http://java.sun.com/applets/

could u be more specific. This entire section is about applets, which i downloaded and read. I seem to have missed a section on how to author an applet.

Quote:
 You really need to stop thinking that you already know all the answers. You know very little (which is totally fine and completely expected for a beginner). You are crippling your learning process by expecting that everything is simple. Programming is hard and takes a month or so before all the building and running of applications becomes 2nd nature.

If i knew everything i wouldnt be asking. And its this way with java: there is no good concise help file on java with search feature and examples (like with c/c++), so u gotta guess a lot of stuff or ask others.

##### Share on other sites
Original post by Palidine
The correct way to allocate a big array in C:
int *myArray = new int[300];//and when you're donedelete[] myArray;

[/quote]

Nope, that's C++. In C, you'd do
int* myArray = malloc(sizeof(int) * 300);//and when you're donefree(myArray);

##### Share on other sites
Quote:
Original post by Palidine
Quote:
 Original post by alexxziusA question: u normally cant run jars just by clicking on them, can u? I did and it gave me an error which said that a binary was missing or something...

I think with some Java VMs you can just double-click jars. It may be a configuration issue. It's been a long time since I've programed client-side java so I don't really know for sure.

-me

The JRE installer on Windows should setup the file association so that .jar files can be started by double-clicking. However some commpression programs (WinRar notably) will pinch the .jar extension for themselves, instead opening them themselves. (An incredably bad move IMHO).

This is one of the reasons why I use JSmooth, which basically generates a tiny .exe file which then launches the Java VM with the jars and command line settings that you configure it with. This way it works as expected on Windows and can't be broken by a badly configured machine.

##### Share on other sites
Quote:
 Original post by alexxziuswow that must be a record for one phrase to be quoted and trashed. . .

Considering all the religious and political threads, I doubt it.

Quote:
 Ive used pointers before so I know a few things. They may be fast, but only in execution sense. They clog up the program which makes it hard to program.

Not when used properly.

Quote:
 *(list+indx)->data[0]=5; // make me wonder what the?

That's just the same as list[index]->data[0] = 5;. Why someone would write it that way, I have no idea.

Quote:
 Correct me if im wrong but Java dont have pointers and it dont miss it a bit.

Pointers are used all the time in Java, but most of the pointer manipulation is done by the compiler, so you don't see it for the most part. All objects are pointers.
Quote:
 (except u cant write viruses in Java)

First of all, yes you can, in theory. Secondly, are you saying you would miss the ability to write viruses?

Quote:
 Maybe its wrong for me to assume that C/C++ is a memory hog, but from past experience my programs crashed when i had an array of more than 300 ints.

It is wrong to assume that. In general, C++ programs use less memory than equivalent Java ones. Like what was said earlier, you were probably allocating the arrays incorrectly, for their size.

##### Share on other sites
Quote:
Original post by alexxzius
Quote:
 int *myArray = new int[300];//and when you're donedelete[] myArray;

again pointers. Thats why i switched to java

Dude, your pointer bashing becomes annoying. You'd better become friends with pointers and references, because that's how computers work with data at the core.

Anyway, you can do it without pointers in C++ if you hate them so much:

std::vector<int> myArray;
myArray.reserve(300);

// myArray will be automatically removed when it goes out of scope

(compiles to a binary full of pointers, but you don't have to deal with 'm directly)

##### Share on other sites
forget pointers.
Yesterday i wasted 3 hours trying to make my JARs work. ... so frustrated ...
Im thinking theres something wrong with my computer. My jars says that it cannot find main class, even though i included it in the Manifest file.

Can anyone try to play any of these games: http://www.4shared.com/dir/2012694/cec9d973/Java_Games.html
They not mine, im not trying to promote anything; just wanna see if u can run them. It gives me this error:
Failed to load Main-Class atribute from C:\Documents and Settings\Desktop\Midnight Pool.jar

If u cant, just gemme a link with a JAR that u can run.

All i wanna do is to make my game write files. There gotta be another way to do it besides putting all the stuff in a jar file (i know java has a lot of little tools and tricks - im sure one of them can be used to write files).

##### Share on other sites
Im not going to quote the other statements (It seems that was done to death),
but:
Quote:
 And i seen .exe files in my Dev-C directory without linking anything (if only java could do that . . .)

Thats because the compilier generates the object files, and automatically
envokes the linker to link them. This wont happen if you "Only Compile".
However, if you "Build the project", it will envoke the linker.