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 


site 4 learning c++
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam
View previous topic :: View next topic  
Author Message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Sat Jan 28, 2012 12:24 pm    Post subject: Reply with quote

im using dev c++... is it different than visual c++.... because im having problem with header files... http://www.learncpp.com/cpp-tutorial/19-header-files/
Back to top
View user's profile Send private message
C-Dizzle
Grandmaster Cheater
Reputation: 89

Joined: 16 Mar 2008
Posts: 623

PostPosted: Sat Jan 28, 2012 12:47 pm    Post subject: Reply with quote

You also need to sort out how your code looks. I'd indent the brackets and cout so it's more indented than the if statement. Same goes with the Pause, make it so it's the same place as return 0;.

Also annotate the fuck out of everything. May sound stupid now but you really need to get practicing with everything you do.
Back to top
View user's profile Send private message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Sat Jan 28, 2012 2:41 pm    Post subject: Reply with quote

Arktri wrote:
You also need to sort out how your code looks. I'd indent the brackets and cout so it's more indented than the if statement. Same goes with the Pause, make it so it's the same place as return 0;.

Also annotate the fuck out of everything. May sound stupid now but you really need to get practicing with everything you do.


something like this:
Code:

#include <iostream>
#include <string>
using namespace std;

int main()
   {
    string x;
    cout <<"Enter password : \n\n";
    cin >> x;
   
    if(x == "blahblahblah")
       {
          cout <<"12345";
       }
         
                           
   
     
system("PAUSE");
return 0;
   
   }
Back to top
View user's profile Send private message
C-Dizzle
Grandmaster Cheater
Reputation: 89

Joined: 16 Mar 2008
Posts: 623

PostPosted: Sat Jan 28, 2012 2:52 pm    Post subject: Reply with quote

Pretty much but more comments and tab the system and return in once.
Back to top
View user's profile Send private message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Sun Jan 29, 2012 4:56 am    Post subject: Reply with quote

i cant get header files working. can any 1 help me?

add.h


main.cpp

Back to top
View user's profile Send private message
C-Dizzle
Grandmaster Cheater
Reputation: 89

Joined: 16 Mar 2008
Posts: 623

PostPosted: Sun Jan 29, 2012 5:42 am    Post subject: Reply with quote

I'm pretty sure you need to add the header to the included directories.
Back to top
View user's profile Send private message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Sun Jan 29, 2012 6:10 am    Post subject: Reply with quote

Arktri wrote:
I'm pretty sure you need to add the header to the included directories.


where is that "included directory"
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: Sun Jan 29, 2012 6:01 pm    Post subject: Reply with quote

You need to give that function a body! All you've done there is give it a signature.

Code:
int add(int x, int y)
{
    return x + y;
}



Then you can

Code:
#include <iostream>
#include "add.h"

int main(int argc, const char * argv[])
{
   std::cout << add(1, 2) << std::endl;
}



(You're compiler should make main() return something AUTOMATICALLY)
Back to top
View user's profile Send private message MSN Messenger
C-Dizzle
Grandmaster Cheater
Reputation: 89

Joined: 16 Mar 2008
Posts: 623

PostPosted: Sun Jan 29, 2012 6:10 pm    Post subject: Reply with quote

Noz3001 wrote:
You need to give that function a body! All you've done there is give it a signature.

Code:
int add(int x, int y)
{
    return x + y;
}



Then you can

Code:
#include <iostream>
#include "add.h"

int main(int argc, const char * argv[])
{
   std::cout << add(1, 2) << std::endl;
}



(You're compiler should make main() return something AUTOMATICALLY)


With the 'std::'. Say I had a cin before cout, would I need to put std:: before them both?
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: Sun Jan 29, 2012 6:20 pm    Post subject: Reply with quote

Arktri wrote:
Noz3001 wrote:
You need to give that function a body! All you've done there is give it a signature.

Code:
int add(int x, int y)
{
    return x + y;
}



Then you can

Code:
#include <iostream>
#include "add.h"

int main(int argc, const char * argv[])
{
   std::cout << add(1, 2) << std::endl;
}



(You're compiler should make main() return something AUTOMATICALLY)


With the 'std::'. Say I had a cin before cout, would I need to put std:: before them both?


Yes, anything in the standard c++ library will need std:: before it in you don't add using namespace std. This is good in big projects, because you can write your own namespace with the same function names and be able to distinguish between them.

std::cout and mynamespace::cout, for example, might do TOTALLY different things


Example for the add function:

Code:
#include <iostream>

namespace example
{
    int add(int x, int y)
    {
        return x + y;
    }
}


int main (int argc, const char * argv[])
{
    std::cout << example::add(1, 3) << std::endl;
}


You should declare namespaces in some header file and give them a counterpart .cpp file though and they can span over various source files. Declaring functions within namespace xxx {} will add them to that namespace no matter what file it is in
Back to top
View user's profile Send private message MSN Messenger
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Mon Jan 30, 2012 7:20 am    Post subject: Reply with quote

ok... thanks
Code:

#ifndef ADD_H


this gives me error.. why?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 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