Page 1 of 1

New to C++

Posted: Sat May 24, 2008 9:18 pm
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.

Posted: Sun May 25, 2008 5:06 am
by xzodia
it should be in the "bin" folder in the directory which you saved the project to

Posted: Sun May 25, 2008 9:07 am
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.

Posted: Sun May 25, 2008 6:03 pm
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

Posted: Sun May 25, 2008 7:59 pm
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.

Posted: Mon May 26, 2008 12:18 am
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.

Posted: Mon May 26, 2008 2:08 am
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.

Posted: Mon May 26, 2008 2:06 pm
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?

Posted: Mon May 26, 2008 6:12 pm
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.

Posted: Wed May 28, 2008 7:47 am
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)...

Posted: Wed May 28, 2008 12:42 pm
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...)

Posted: Wed May 28, 2008 2:09 pm
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

Posted: Wed May 28, 2008 9:15 pm
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.

Posted: Thu May 29, 2008 6:03 am
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