| View previous topic :: View next topic |
| Author |
Message |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Sun Oct 07, 2007 11:27 am Post subject: |
|
|
| I would just open the exe from the cmd.. |
|
| Back to top |
|
 |
happydud3 Advanced Cheater
Reputation: 0
Joined: 07 Dec 2006 Posts: 86
|
Posted: Sun Oct 07, 2007 3:07 pm Post subject: |
|
|
guys i need help aswell ROFL. i just started c++ and this is wat i got.
| Code: | #include <iostream.h>
#include <string.h>
void main ()
{
char name[8];
short cost;
float amount;
float totalsale;
cout << "Name of the customer: ";
cin.getline(name, 8);
cout << "What does it cost: ";
cin >> cost;
cout << "What is the amount: ";
cin >> amount;
totalsale = (float)amount * (float)cost;
cout << endl;
cout << "Customer name: " << name << endl;
cout << "The amount wanted: " << amount << endl;
cout << "The cost of the item is: " << cost << endl;
cout << "The total sale is: $" << totalsale << endl;
} |
i dont get wat void main () is suppose to do
and and | Code: | char name[8] = " ";
short cost = 0;
float amount = 0.0;
float totalsale = 0.0;
char name[8];
short cost;
float amount;
float totalsale; |
whats the difference between these two codes?
Last edited by happydud3 on Sun Oct 07, 2007 11:33 pm; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Oct 07, 2007 3:09 pm Post subject: |
|
|
void main() is the entry point of your program. (Console app.) It is the first thing to be called when its loaded. Without an entry point, your program will not do anything, and in most cases wont compile.
It is also suggested not to use void for the entry point but instead to use a returning type such as int or boolean.
| Code: | int main()
{
// your code here
} |
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Mon Oct 08, 2007 6:00 am Post subject: |
|
|
| happydud3 wrote: | and and | Code: | char name[8] = " ";
short cost = 0;
float amount = 0.0;
float totalsale = 0.0;
char name[8];
short cost;
float amount;
float totalsale; |
whats the difference between these two codes? | Well.. Wiccan answered the first part, I'll answer the second one; The first one initializes the variables with "reasonable" values, whereas the later one doesn't. If you try printing those last ones, you'll probably get some random values, like 1234... Print them and you will see. |
|
| Back to top |
|
 |
Acim Grandmaster Cheater Supreme
Reputation: 0
Joined: 04 Jun 2007 Posts: 1948 Location: If anyone has a GMS DK and they don't need it I'll have it!!
|
Posted: Mon Oct 08, 2007 8:52 am Post subject: |
|
|
Still cant get C++ to work, so I dled Delphi now its asking me for a freakin serial number. _________________
I'm alive and well, but I quit CEF for a while. Legitly playing since Novemberish 07. Starting hacking October 06. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Oct 08, 2007 9:07 am Post subject: |
|
|
| Acim wrote: | | Still cant get C++ to work, so I dled Delphi now its asking me for a freakin serial number. |
Post your errors or any other issues you are having. |
|
| Back to top |
|
 |
Acim Grandmaster Cheater Supreme
Reputation: 0
Joined: 04 Jun 2007 Posts: 1948 Location: If anyone has a GMS DK and they don't need it I'll have it!!
|
Posted: Mon Oct 08, 2007 9:25 am Post subject: |
|
|
| Moose wrote: |
| Code: | | while (! _kbhit()) Sleep(0); |
|
Lemme try.
Hmm... maybe I just suck at C++. Thanks for eveyrone trying but im moving to serial-key-Delphi. _________________
I'm alive and well, but I quit CEF for a while. Legitly playing since Novemberish 07. Starting hacking October 06. |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Mon Oct 08, 2007 10:27 am Post subject: |
|
|
|
|
| Back to top |
|
 |
Qvazzler Advanced Cheater
Reputation: 0
Joined: 02 Jan 2007 Posts: 68
|
Posted: Tue Oct 09, 2007 5:33 am Post subject: |
|
|
| Flyte wrote: | | Flyte wrote: | | x0r wrote: | I didn't know iostream provided it's own Sleep function
|
My bad, too many C programming habits.
You know what I was getting at though. |
|
I don't remember windows having it's own sleep function inside iostream.. Isn't that only on linux? |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Tue Oct 09, 2007 1:15 pm Post subject: |
|
|
| Qvazzler wrote: | | I don't remember windows having it's own sleep function inside iostream.. Isn't that only on linux? |
sleep is linux (lowercase s, seconds, unistd.h)
Sleep is windows(uppercase s, milliseconds, winbase.h )
Last edited by appalsap on Tue Oct 09, 2007 6:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Oct 09, 2007 5:49 pm Post subject: |
|
|
| appalsap wrote: | | Sleep is windows(uppercase s, milliseconds, windows.h) |
Sleep for Windows is located in winbase.h just fyi. Auto included if you include windows.h if you need everything. |
|
| Back to top |
|
 |
|