Staredit Newtork
Community
StarCraft
Games
Site
Favourites
Programing, -Career

Pages: < 1 « 3 4 5 6 7 >
Creator: Brontobyte
Time: May 20 2008, 11:48 pm

Post #81     Brontobyte May 23 2008, 12:23 am

[Avatar]
 offline contact
I don't even know the first thing to do..

How do I "compile" my source code into a program? Can I do it through the C++ program or do I need to download more stuff?
This post was edited 1 time, last edit by Brontobyte: May 23 2008, 12:31 am.
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #82     cheeze May 23 2008, 12:31 am

[Avatar]
 offline contact
Quote
No. Your program shouldn't need to do this. Console programs are meant to be executed from the console, and as such, the output should still be on the screen.
There's no such thing as "meant to be executed from the console" except commands. Programs can be executed on the console. But note that I mainly develop in linux and compiling/running is usually done on the console (except for big projects, but even those!) so what I meant was, any output would still be in the console, even with the program's termination.

Quote
I don't even know the first thing to do..
Just do what I said. It's post #70 in this thread.
Top

Post #83     Heimdal May 23 2008, 1:19 am

[Avatar]
 offline contact
Quote from cheeze
Quote
No. Your program shouldn't need to do this. Console programs are meant to be executed from the console, and as such, the output should still be on the screen.
There's no such thing as "meant to be executed from the console" except commands. Programs can be executed on the console. But note that I mainly develop in linux and compiling/running is usually done on the console (except for big projects, but even those!) so what I meant was, any output would still be in the console, even with the program's termination.
Exactly. I was correcting the guy who said "put cin.get()" at the end. Guess the quote boxes weren't clear :)
Quote
Quote
I don't even know the first thing to do..
Just do what I said. It's post #70 in this thread.
Or follow my instructions in post #75. When you're ready to run your code, press ctrl-F5. or Debug->Start without debugging.
Top

Post #84     Brontobyte May 23 2008, 6:52 pm

[Avatar]
 offline contact
I did that and then what do I do? How do I see a preview of what I just worked on? What do I type to start? I have so many questions...
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #85     cheeze May 23 2008, 7:10 pm

[Avatar]
 offline contact
You didn't do everything we said then. =|
If you're trying Dev-C++ (which is what I highly suggest currently as it gives the cleanest coding experience in Windows), just start a new file and call it "main.cpp".

Copy and paste the code I showed you into the editor, save it and in the toolbars, there should be a "compile" and/or "run" button. Click on that button to run the file.

Due to the fact that windows is weird, insert the code: "cin.get()" right before "return 0", otherwise, the console will automatically close and you won't see anything. To exit the program, just press enter. Note that the program is simply waiting for an input (cin.get()) before it executes "return 0" which closes the program.

For now, just see if you can get that working. And tell us exactly what you did if you can't get it working.
Top

Post #86     Heimdal May 23 2008, 7:16 pm

[Avatar]
 offline contact
Do you have a .cpp file in the project? Copy and paste the following into it and then hit ctrl-F5.

Code

#include <iostream>

using namespace std;

int main()
{
   cout << "Hello, world!" << endl;
   return 0;
}


Try getting it to print different things. When you're bored of that, copy and paste this:

Code

#include <iostream>
#include <string>

using namespace std;

int main()
{
   string name;
   cout << "Enter your name:" << endl;
   cin >> name;
   cout << "Hello, " << name << "!" << endl;

   return 0;
}


And then from there, start reading: http://www.cplusplus.com/doc/tutorial/program_structure.html
Top

Post #87     O)FaRTy1billion[MM] May 23 2008, 8:47 pm

[Avatar]
Remember the game! P.s.: Feldspar.
 offline contact
Quote from Heimdal
That said...if your console program is meant to be double-clicked from windows, adding

Code

system("pause");
before the return 0; is the right way to go. But this only works for windows.
Gross.
That's only if you want the ugly "Press any key to exit . . ." or whatever.
>The Game!<
>Taking SCD4 Suggestions!<
Clicky, Clicky!
Top

Post #88     Doodle77[MM] May 23 2008, 9:29 pm

[Avatar]
 offline contact
Quote from O)FaRTy1billion[MM]
Quote from Heimdal
That said...if your console program is meant to be double-clicked from windows, adding

Code

system("pause");
before the return 0; is the right way to go. But this only works for windows.
Gross.
That's only if you want the ugly "Press any key to exit . . ." or whatever.
It's so much more awesome to use:

Code

while (!kbhit());

remember to include conio.h (though mine has it in stdio.h also).
Top

Post #89     Brontobyte May 24 2008, 1:19 pm

[Avatar]
 offline contact
The "alt + F5" didn't work. I opened my file "Project 1" and then went to the left side tree and clicked on the main.cpp file and then went to the right side and copy and pasted the code you provided, hit alt + F5 and nothing happened. :-(
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #90     Merrell May 24 2008, 1:25 pm

[Avatar]
 offline contact
Ctrl + F5
Top

Post #91     Brontobyte May 24 2008, 1:55 pm

[Avatar]
 offline contact
Quote from WoAHorde[MM]
You want a cin.get(); instead of a return 0; so the program remains open.

This only works once until you hit a key or type something in followed by the enter, then the message comes back up again. Is there some number that I am supposed to input into the "()" area to make it last forever?

Quote from Merrell
Ctrl + F5

<3 YEAH! It worked! Now all that I have to do is learn some code that can actually be used for something decent and BAM! Is there a list somewheres that has every code with what it does? *Starts to Google*
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #92     Money May 24 2008, 2:51 pm

[Avatar]
*shreds*
 offline contact
Quote from Brontobyte
Quote from WoAHorde[MM]
You want a cin.get(); instead of a return 0; so the program remains open.

This only works once until you hit a key or type something in followed by the enter, then the message comes back up again. Is there some number that I am supposed to input into the "()" area to make it last forever?

You don't want it to continue when you hit enter?

Quote from Brontobyte
Quote from Merrell
Ctrl + F5

<3 YEAH! It worked! Now all that I have to do is learn some code that can actually be used for something decent and BAM! Is there a list somewheres that has every code with what it does? *Starts to Google*

Umm, that would be one HUGE list. Depends on what libraries you are using.
(user posted image)
Top

Post #93     Brontobyte May 24 2008, 9:23 pm

[Avatar]
 offline contact
Quote from Money
Quote from Brontobyte
Quote from WoAHorde[MM]
You want a cin.get(); instead of a return 0; so the program remains open.

This only works once until you hit a key or type something in followed by the enter, then the message comes back up again. Is there some number that I am supposed to input into the "()" area to make it last forever?

You don't want it to continue when you hit enter?

Quote from Brontobyte
Quote from Merrell
Ctrl + F5

<3 YEAH! It worked! Now all that I have to do is learn some code that can actually be used for something decent and BAM! Is there a list somewheres that has every code with what it does? *Starts to Google*

Umm, that would be one HUGE list. Depends on what libraries you are using.

I want it to be able to stay open even after you enter commands, valid or not valid.

I would just want a basic list of code so that I can familiarize myself with it.
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #94     WoAHorde[MM] May 24 2008, 9:44 pm

[Avatar]
Resident Spy
 offline contact
Use a while loop then.
Top

Post #95     Brontobyte May 24 2008, 9:56 pm

[Avatar]
 offline contact
Quote from WoAHorde[MM]
Use a while loop then.

I have no idea how to do this.
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #96     WoAHorde[MM] May 24 2008, 10:37 pm

[Avatar]
Resident Spy
 offline contact

Code

// While loop example
#include <iostream>

using namespace std;

int main ()

{
   int a,b,c;
   a = 1;
   
   cout << "Go" "\n";
   cin>> c;
   cin.ignore();
   
   while (a==1)
   
   if (c==1) {
      cout << "Input a number to be cubed." "\n";
      cin>> b;
      cout << b * b * b "\n";
      cin.get();
      cout << "Press 1 if you wish to go again" "\n";
      cin>> c;
      cin.get();
      }
   else if (c > 1, c < 1) {
        return 0;
        }

}


A quick program I made to demonstrate.
Top

Post #97     Brontobyte May 24 2008, 10:57 pm

[Avatar]
 offline contact
It didn't work...
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #98     DT_Battlekruser May 24 2008, 11:04 pm

[Avatar]
I paid eleven minerals for THIS?
 offline contact
What is with C and using >> and << as syntax :wtfage:

Also, I assume that


Code

  while (a==1)
 
  if (c==1) {
     cout << "Input a number to be cubed." "\n";
     cin>> b;
     cout << b * b * b "\n";
     cin.get();
     cout << "Press 1 if you wish to go again" "\n";
     cin>> c;
     cin.get();
     }
  else if (c > 1, c < 1) {
       return 0;
       }


is equivalent to

Code

  while (a==1) {
     if (c==1) {
        cout << "Input a number to be cubed." "\n";
        cin>> b;
        cout << b * b * b "\n";
        cin.get();
        cout << "Press 1 if you wish to go again" "\n";
        cin>> c;
        cin.get();
     }
     else if (c > 1, c < 1) {
        return 0;
     }
  }


...but I hate lazy syntax.
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #99     Brontobyte May 24 2008, 11:17 pm

[Avatar]
 offline contact
------ Build started: Project: Calculator, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\admin\my documents\visual studio 2008\projects\calculator\calculator\main.cpp(20) : error C2143: syntax error : missing ';' before 'string'
c:\documents and settings\admin\my documents\visual studio 2008\projects\calculator\calculator\main.cpp(30) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\admin\my documents\visual studio 2008\projects\calculator\calculator\main.cpp(8)' was matched
Build log was saved at "file://c:\Documents and Settings\Admin\My Documents\Visual Studio 2008\Projects\Calculator\Calculator\Debug\BuildLog.htm"
Calculator - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

"There are build errors..."
╔═══╦═══╦═══╦══╦═╦═══╦═══╦═══╦═╦═╦═══╦═══╗
╠═══╣....═╣............╠╗..╔╣....╠═══╬╗..╔╩╗..╔╬═══╣
╚═══╩═╩═╩═══╩═╩══╩╩═╩╩═══╩═══╩╩═╩═╩═╩╩═══╝
Top

Post #100     Epsilonite May 25 2008, 5:00 am

[Avatar]
 offline contact
Line 20

Code

cout << b * b * b "\n";
should be replaced with this:

Code

cout << b * b * b << "\n";


EDIT:
Forgot to include the fix to the other error message.

You need a closing brace "}" for the main() function, which you probably deleted by accident somehow.
This post was edited 1 time, last edit by Epsilonite: May 25 2008, 6:03 am.
Top
0 members in this topic: None
+ 0 guest(s)


[05:11 pm]
DeVouReR -- tassa zera?
[05:02 pm]
ClansAreForGays -- its on the front page Temple Siege Tournament
[04:33 pm]
DeVouReR -- I sent 74 PMs and it displays PM'S: 125/125 left: 0... wtf?