Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Request] Help on C++
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
patsmokeswii
Grandmaster Cheater Supreme
Reputation: 0

Joined: 26 Aug 2007
Posts: 1039
Location: Perth Amboy, NJ

PostPosted: Tue Jan 22, 2008 10:21 am    Post subject: [Request] Help on C++ Reply with quote

Well, I am trying to begin programing, and learning how to do stuff, so I am wondering, why is it I get an error with "Hello World" in Microsoft visual studio '08.


This is what I write:

Code:

#include <iostream>
using namespace std;

main()
{
  cout << "Hello World!" << ;
 
}


I used Buzz's tutorials, which are video tutorials by the way, and thats how he wrote it.

I get this error saying I have no submain therefore the program can't be compiled and run properly. Any help?

Edit:
This is how I built the program this time, it ran, but just exited right away..

Code:

#include <iostream>
using namespace std;

sub main()
{
    cout << "Hello World!" ;
}
End sub main


Whats wrong?


Last edited by patsmokeswii on Tue Jan 22, 2008 11:50 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Tue Jan 22, 2008 11:22 am    Post subject: Reply with quote

You need int or void in front of main. Also, you need to put something after the <<. If not, you don't need it.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Jan 22, 2008 2:22 pm    Post subject: Reply with quote

how the hell did you manage to compile that?

Code:
#include <iostream>

int main(void)
{
   std::cout << "Hello world!";
   return 0;
}
Back to top
View user's profile Send private message
patsmokeswii
Grandmaster Cheater Supreme
Reputation: 0

Joined: 26 Aug 2007
Posts: 1039
Location: Perth Amboy, NJ

PostPosted: Tue Jan 22, 2008 3:04 pm    Post subject: Reply with quote

Easy, by pressing F5 XD.

It compiles and runs the program.

But, I might just get another compiler.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Tue Jan 22, 2008 3:25 pm    Post subject: Reply with quote

Code:
#include <iostream>

int main()
{
std::cout << "Hello CEF\n";
std::cin.get();
return 0;
}


You do not use vb functions such as sub main

You use int preferably so you have a return value. This means if the commands are run successfully the program will return a value of 0. If not, something went wrong.

_________________
Back to top
View user's profile Send private message
patsmokeswii
Grandmaster Cheater Supreme
Reputation: 0

Joined: 26 Aug 2007
Posts: 1039
Location: Perth Amboy, NJ

PostPosted: Tue Jan 22, 2008 3:29 pm    Post subject: Reply with quote

blankrider wrote:
Code:
#include <iostream>

int main()
{
std::cout << "Hello CEF\n";
std::cin.get();
return 0;
}


You do not use vb functions such as sub main

You use int preferably so you have a return value. This means if the commands are run successfully the program will return a value of 0. If not, something went wrong.


I get so many errors with that one though. The only one that works is the first one, but it just instantly closes.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Jan 22, 2008 4:34 pm    Post subject: Reply with quote

post the errors.
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Tue Jan 22, 2008 5:33 pm    Post subject: Reply with quote

lol, thats what you get when you learn VB 1st.... Rolling Eyes


Code:
End sub main


Rofl
Back to top
View user's profile Send private message MSN Messenger
patsmokeswii
Grandmaster Cheater Supreme
Reputation: 0

Joined: 26 Aug 2007
Posts: 1039
Location: Perth Amboy, NJ

PostPosted: Tue Jan 22, 2008 5:36 pm    Post subject: Reply with quote

OK, here it is:





Code:
'Sub Main' was not found in 'project 1'


Thats the error I get.

Edit: Noz, I didn't learn VB first. To make it work, I had to put that.. I don't know why... that was the only way I wouldn't get the error.

I am just starting to learn now, I have never ever studied VB...
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Tue Jan 22, 2008 5:44 pm    Post subject: Reply with quote

You ARE using a C++ compiler right?
Back to top
View user's profile Send private message MSN Messenger
patsmokeswii
Grandmaster Cheater Supreme
Reputation: 0

Joined: 26 Aug 2007
Posts: 1039
Location: Perth Amboy, NJ

PostPosted: Tue Jan 22, 2008 6:26 pm    Post subject: Reply with quote

noz3001 wrote:
You ARE using a C++ compiler right?


M.V.S. '08

Why?
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Tue Jan 22, 2008 6:35 pm    Post subject: Reply with quote

Code:
#include <iostream>
using namespace std;

sub main()
{
    cout << "Hello World!" ;
}
End sub main


If that compiles in it..... ;

Code:
#include <iostream>
 
int main()
{
       std::cout << "Hello CEF\n";
       std::cin.get();
       return 0;
}


But that doesn't...;

It simply isn't the correct compiler.
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Jan 22, 2008 6:37 pm    Post subject: Reply with quote

just take a picture of these errors, and don't crop it so we can see the IDE. Because I don't know how it's possible for that one snippet to even think about compiling.
Back to top
View user's profile Send private message
wunder312355
Grandmaster Cheater
Reputation: -1

Joined: 14 May 2007
Posts: 568

PostPosted: Tue Jan 22, 2008 6:52 pm    Post subject: Reply with quote

This should work 100%
Its the bare minimum using namespace.

Code:
#include <iostream>

using namespace std;
int main()
{
   cout << "Hello World!" << endl;
   system("pause");
}
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jan 22, 2008 8:26 pm    Post subject: Reply with quote

thefun25 wrote:
This should work 100%
Its the bare minimum using namespace.

Code:
#include <iostream>

using namespace std;
int main()
{
   cout << "Hello World!" << endl;
   system("pause");
}



You should avoid using syste("pause") to catch input to "freeze" the console from closing. This creates a huge overhead in your program and performance loss occurs.

http://www.gidnetwork.com/b-61.html

Instead, use:

Code:
cin.ignore();
cin.sync();

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites