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 


[C++] Error problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
RusBoi
Master Cheater
Reputation: -1

Joined: 07 Apr 2008
Posts: 343

PostPosted: Thu Dec 25, 2008 12:10 pm    Post subject: [C++] Error problem Reply with quote

Well iI just started learning C++ couple of days ago and I ran in to this problem.

My Code
Quote:
// This is a comment
// This program will accept numbers and display their sum

#include <C++2.h>
using namesplace std;
void main()
{
// define variable
float num1;
float num2;
float total;

//Enter date for the variable
cout << "Enter a value for the first variable: ";
cin >> num1;
cout << "Enter a value for the first variable: ";
cin >> num2;

// Add the two numbers together
total = num1 + num2;
//Display the result
cout << "The sum of the numbers = " << total;

}

My Header
Quote:
#include <iostream>



This is the Output
Quote:
1>------ Build started: Project: C++2, Configuration: Debug Win32 ------
1>Compiling...
1>C++2.cpp
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(4) : fatal error C1083: Cannot open include file: 'C++2.h': No such file or directory
1>Build log was saved at "file://c:\Documents and Settings\Chris\My Documents\Visual Studio 2008\Projects\C++2\C++2\Debug\BuildLog.htm"
1>C++2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


What am I doing wrong? All the files are in the same folder as in "C++2.cpp" and "C++2.h" so idk what I'm doing wrong.

_________________
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Thu Dec 25, 2008 12:12 pm    Post subject: Reply with quote

when including your own header file use qoutes around the names

ex: #include "C++2.h"

regards BanMe
Back to top
View user's profile Send private message MSN Messenger
RusBoi
Master Cheater
Reputation: -1

Joined: 07 Apr 2008
Posts: 343

PostPosted: Thu Dec 25, 2008 12:15 pm    Post subject: Reply with quote

OK well I have done that, it seems it fixed the problem but now i get this for my Output.

Quote:
1>------ Build started: Project: C++2, Configuration: Debug Win32 ------
1>Compiling...
1>C++2.cpp
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(5) : error C2146: syntax error : missing ';' before identifier 'std'
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(5) : error C2873: 'namesplace' : symbol cannot be used in a using-declaration
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(5) : error C2365: 'std' : redefinition; previous definition was 'namespace'
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(14) : error C2065: 'cout' : undeclared identifier
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(15) : error C2065: 'cin' : undeclared identifier
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(16) : error C2065: 'cout' : undeclared identifier
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(17) : error C2065: 'cin' : undeclared identifier
1>c:\documents and settings\chris\my documents\visual studio 2008\projects\c++2\c++2\c++2.cpp(22) : error C2065: 'cout' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\Chris\My Documents\Visual Studio 2008\Projects\C++2\C++2\Debug\BuildLog.htm"
1>C++2 - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




My Code NEW:

Quote:
// This is a comment
// This program will accept numbers and display their sum

#include "C++2.h"
using namesplace std;
void main()
{
// define variable
float num1;
float num2;
float total;


//Enter date for the variable
cout << "Enter a value for the first variable: ";
cin >> num1;
cout << "Enter a value for the first variable: ";
cin >> num2;

// Add the two numbers together
total = num1 + num2;
//Display the result
cout << "The sum of the numbers = " << total;

}


My Header NEW:
Quote:
#include <iostream>

_________________
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Dec 25, 2008 12:21 pm    Post subject: Reply with quote

Code:
// This is a comment
// This program will accept numbers and display their sum

#include <iostream>
using namespace std;
void main()
{
// define variable
float num1;
float num2;
float total;

//Enter date for the variable
cout << "Enter a value for the first variable: ";
cin >> num1;
cout << "Enter a value for the first variable: ";
cin >> num2;

// Add the two numbers together
total = num1 + num2;
//Display the result
cout << "The sum of the numbers = " << total;

}


Just take out your header file and include iostream in your .cpp. Also please use [code][\code] and not the quotes.

And it is

Code:
using namespace std;


you just spelled it wrong.

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
RusBoi
Master Cheater
Reputation: -1

Joined: 07 Apr 2008
Posts: 343

PostPosted: Thu Dec 25, 2008 12:25 pm    Post subject: Reply with quote

THANK YOU ! IT WORKS !
_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Dec 25, 2008 4:22 pm    Post subject: Reply with quote

btw, int main()
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Thu Dec 25, 2008 5:16 pm    Post subject: Reply with quote

btw my coochie, void main will work.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
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: Thu Dec 25, 2008 5:27 pm    Post subject: Reply with quote

ElectroFusion wrote:
btw my coochie, void main will work.


Let me refer you to http://users.aber.ac.uk/auj/voidmain.shtml for the 50th time today.
Back to top
View user's profile Send private message MSN Messenger
crayzbeef
Expert Cheater
Reputation: 0

Joined: 21 Jan 2007
Posts: 101

PostPosted: Fri Dec 26, 2008 10:39 am    Post subject: Reply with quote

For fucks sake, Who taught you this ? void main? Are you shitting me?
Back to top
View user's profile Send private message
xV
I post too much
Reputation: 1

Joined: 03 Jan 2008
Posts: 3783
Location: Seattle

PostPosted: Fri Dec 26, 2008 3:54 pm    Post subject: Reply with quote

crayzbeef wrote:
For fucks sake, Who taught you this ? void main? Are you shitting me?


All the tuts I've read tell me "int main ()" I never even knew "void main ()" existed until now. Yeah, still learning.
Back to top
View user's profile Send private message MSN Messenger
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Fri Dec 26, 2008 5:23 pm    Post subject: Reply with quote

ElectroFusion wrote:
btw my coochie, void main will work.

I thought even YOU would learn not to use this by now. But i guess your wrong. You're stupidity extends past my comprehension.

_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
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