New to C++

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
noxiousraccoon




Wordewatician 250

Posts: 441
Joined: Wed May 17, 2006 2:54 pm

New to C++

Post by noxiousraccoon »

Had a quick question involving compiling code. Does a c++ compiler actually output a program, or does it just compile it so you can use it later? I am using Windows Visual C++ as my compiler. I am familiar with Java and Dr. Scheme so the language shouldnt be too hard to comprehend, though I cant quite figure out how to actually get my programs to run.
After compiling I get this:
1>Testing - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

So I am pretty confident my code is correct, though I see no output. Anyone have a suggestion?

Also, if anyone is willing. After looking at the language, I havent quite figured out the use of (*) or the pointer. I have looked at tutorials and such, but I really dont see what it is actually doing. Could anyone enlighten me? I would appreciate it.
Image
Image
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Post by xzodia »

it should be in the "bin" folder in the directory which you saved the project to
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

Yes compilers do output a program. I would probably take a course on C++ if you want to learn it, for now I would stick to a managed language like C#(very similar to java) or java where you don't have to deal with pointers.
User avatar
noxiousraccoon




Wordewatician 250

Posts: 441
Joined: Wed May 17, 2006 2:54 pm

Post by noxiousraccoon »

I already know Java, thats why I want to learn C++. I could take the time to learn C# as well. Dr. Scheme is better than all these languages anyways, atleast in my opinion.

xzodia, I dont have a "bin" folder
Image
Image
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

Dr Scheme is a program that has support for multiple languages, I'm assuming you mean you prefer the scheme language. I don't like the syntax of it personally, that's what I started in for computers, besides a brief course that use VB.net :( As for you question about pointers, I believe that when you use * it declares a pointer variable, which stores an address to the location of an object in memory. I would try to explain more but I'm not positive on everything so I don't want to tell you incorrect information.
User avatar
noxiousraccoon




Wordewatician 250

Posts: 441
Joined: Wed May 17, 2006 2:54 pm

Post by noxiousraccoon »

Ya, I prefer the syntax. I'm also looking at Python as well, but I wanted to learn C++. Still having trouble getting output though.
Image
Image
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

Maybe you should learn the advantages of programs based off an intermediate language running inside the .NET environment...you would never want to go back to python. :P


Also, C# supports pointer controls and unsafe programming.
...left for good
User avatar
noxiousraccoon




Wordewatician 250

Posts: 441
Joined: Wed May 17, 2006 2:54 pm

Post by noxiousraccoon »

Patrickssj6 wrote:Maybe you should learn the advantages of programs based off an intermediate language running inside the .NET environment...you would never want to go back to python. :P
Also, C# supports pointer controls and unsafe programming.
Im really just interested in learning more languages, not really looking for advantages or disadvantages.

Does anyone have a suggestion on the compiler problem?
Image
Image
User avatar
[cc]z@nd!




Literarian 500

Posts: 2297
Joined: Tue May 04, 2004 1:52 pm
Location: michigan

Post by [cc]z@nd! »

imo visual studio isn't that great of an IDE, although that might just be because i'm used to working in dev-c++ (it's free and uses the g++ compiler). i'm also not sure what compiler visual studio uses, so i'm not sure if i could help you on that, since i don't know where it puts the program after it's compiled, but it should just be a matter of finding it. once you've found it, if it disappears when you double-click it you'll want to try navigating to it in the command line and running it from there.

c++ compilers take your code, do something called linking i'm not familiar with involving object files or something, then compile those into a single executable file in machine language (iirc).

as for pointers, like 0wnz said, they're a variable that holds a memory address. you'll declare them like this: "int *pointer;" and assign addresses to them with the dereferencing operator ("&"). like this if i'm not too rusty.

Code: Select all

int *pointer; //pointer declared, but not initialized
int target; //what we'll point to. declared, but not initialized, so it holds junk data.
pointer = ⌖ //pointer = address-of target.
now such statements will be equal:

Code: Select all

*pointer = 42; //i'm fairly sure this is right, i might be wrong on putting the * there, though.
target = 42;
they're good for dealing with large amounts of data, like if you made a class that holds large amounts of info, then have a function that compares two classes. instead of passing the entire classes to the function and having to copy all that data, you could simply pass it the address of the classes in memory, so it can work with them directly and only move around a few bytes of info (the addresses). you probably won't have to worry about working with them for a while, i still don't use them much.
ASPARTAME: in your diet soda and artificial sweeteners. also, it's obviously completely safe. it's not like it will cause tumors or anything. >.>
always remember: guilty until proven innocent
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

[cc]z@nd! wrote: c++ compilers take your code, do something called linking i'm not familiar with involving object files or something, then compile those into a single executable file in machine language (iirc).
If you compile a file inside the .NET Framework it gets converted into the IL (Intermediate Language). They are all Exe files and by that all PE files but there is an essential difference. .NET Application get decompiled on startup and get optimized for the used CPU (from IL to MachineCode)...
...left for good
User avatar
FleetAdmiralBacon




Critic Pyre Articulatist 500

Posts: 2377
Joined: Sat Nov 26, 2005 7:01 pm
Location: Ohio
Contact:

Post by FleetAdmiralBacon »

Patrickssj6 wrote: If you compile a file inside the .NET Framework it gets converted into the IL (Intermediate Language). They are all Exe files and by that all PE files but there is an essential difference. .NET Application get decompiled on startup and get optimized for the used CPU (from IL to MachineCode)...
A PE isn't technically machine code. The process used when running a .NET application is dynamic translation, the CLR takes your MSIL executable and performs a JIT compilation on it to make native code, but they are not decompiled. (Also, as a note, not all EXEs are PEs, even up in Vista you still have a few LEs or even possibly an MZ (gasp!). I think I've also seen an NE or two as well, old 16-bit programs still lurk in the core...)
Image
Everything you'll ever need to know about me.
Need help with Linux, C#, C, Python, Java, PHP, Javascript, CSS, or VB? I'm available from 3:00PM-8:00PM EST on weekdays.
User avatar
McT0asT





Posts: 257
Joined: Wed Feb 28, 2007 2:00 pm
Location: The Park(New Mombasa)

Post by McT0asT »

noxiousraccoon wrote: Does anyone have a suggestion on the compiler problem?
Try looking in the
"C:\Documents and Settings\*USERNAME*\My Documents\Visual Studio 200*\Projects\*Project Name*\*Project Name*\bin\Release" folder
Remembering the good times...
[Ace Mods] [Mod Sqwad]
User avatar
noxiousraccoon




Wordewatician 250

Posts: 441
Joined: Wed May 17, 2006 2:54 pm

Post by noxiousraccoon »

McT0asT wrote:
noxiousraccoon wrote: Does anyone have a suggestion on the compiler problem?
Try looking in the
"C:\Documents and Settings\*USERNAME*\My Documents\Visual Studio 200*\Projects\*Project Name*\*Project Name*\bin\Release" folder
I didnt put it in that location, but where i do have it, it doesnt have a bin folder. Only a 'debug' file, the necessary source code files, and a few others.
Image
Image
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

FleetAdmiralBacon wrote:
Patrickssj6 wrote: If you compile a file inside the .NET Framework it gets converted into the IL (Intermediate Language). They are all Exe files and by that all PE files but there is an essential difference. .NET Application get decompiled on startup and get optimized for the used CPU (from IL to MachineCode)...
A PE isn't technically machine code. The process used when running a .NET application is dynamic translation, the CLR takes your MSIL executable and performs a JIT compilation on it to make native code, but they are not decompiled. (Also, as a note, not all EXEs are PEs, even up in Vista you still have a few LEs or even possibly an MZ (gasp!). I think I've also seen an NE or two as well, old 16-bit programs still lurk in the core...)
Yeah thanks. I wanted to keep it short and understandable :P
...left for good
Post Reply