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 


What's wrong with this script? (C++)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Negima
I post too much
Reputation: 6

Joined: 22 May 2007
Posts: 2220

PostPosted: Sun Mar 23, 2008 9:23 pm    Post subject: What's wrong with this script? (C++) Reply with quote

Code:
#include <iostream.h>

int main(void)
{
   
    cout << "Hello User!" " My name is JCoA\n" "There are many things that I can help you with\n" "I can do things such as: \n" "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";
    system("pause");
    delay(2000);
    return 0;
   
}


It worked until I added the "delay(2000);" a member of CEF told me that it would work but I have had no luck with it.
Back to top
View user's profile Send private message Visit poster's website
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Mar 23, 2008 9:35 pm    Post subject: Reply with quote

Code:
#include <iostream>

int main()
{
     std::cout << "Hello User!" << " My name is JCoA\n" << "There are many things that I can help you with\n" <<  "I can do things such as: \n" << "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";
     std::cin.sync();
     std::cin.ignore();
     return 0;
}


If you want a delay, #include <windows.h> and use the Sleep API

_________________
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sun Mar 23, 2008 10:10 pm    Post subject: Reply with quote

Also, in case you didn't notice, he dropped your system("pause") command, and replaced it with a much better way of doing it.

If you want to know why it's so bad, Gewgle is your friend.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Negima
I post too much
Reputation: 6

Joined: 22 May 2007
Posts: 2220

PostPosted: Sun Mar 23, 2008 10:22 pm    Post subject: Reply with quote

Thanks guys, another question I have is how would I include two headers in 1 script so I can write things onto the screen with the iostream.h header and use the sleep API with windows.h

(I'm fairly new to C++)
Back to top
View user's profile Send private message Visit poster's website
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sun Mar 23, 2008 10:34 pm    Post subject: Reply with quote

Negima wrote:
Thanks guys, another question I have is how would I include two headers in 1 script so I can write things onto the screen with the iostream.h header and use the sleep API with windows.h

(I'm fairly new to C++)


Code:

#include <iostream>
#include <windows.h>

//rest of your code here

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Negima
I post too much
Reputation: 6

Joined: 22 May 2007
Posts: 2220

PostPosted: Sun Mar 23, 2008 10:43 pm    Post subject: Reply with quote

Then why won't this work:

Code:
#include <iostream.h>
#include <windows.h>

int main(void)
{
    cout << "Hello User!" " My name is JCoA\n" "There are many things that I can help you with\n" "I can do things such as: \n" "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";   
    sleep(2000);
    system("pause");   
    return 0;
}



I keep getting an error in line 7 known as line undeclared
Back to top
View user's profile Send private message Visit poster's website
XxOsirisxX
Grandmaster Cheater Supreme
Reputation: 0

Joined: 30 Oct 2006
Posts: 1597

PostPosted: Sun Mar 23, 2008 11:19 pm    Post subject: Reply with quote

Negima wrote:
Then why won't this work:

Code:
#include <iostream.h>
#include <windows.h>

int main(void)
{
    cout << "Hello User!" " My name is JCoA\n" "There are many things that I can help you with\n" "I can do things such as: \n" "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";   
    sleep(2000);
    system("pause");   
    return 0;
}



I keep getting an error in line 7 known as line undeclared


Iono if that may be the error...

But, you have no included in that code "using namespace std;"

so cout, would be std::cout

_________________

Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Mar 24, 2008 7:54 am    Post subject: Reply with quote

Negima wrote:
Then why won't this work:

Code:
#include <iostream.h>
#include <windows.h>

int main(void)
{
    cout << "Hello User!" " My name is JCoA\n" "There are many things that I can help you with\n" "I can do things such as: \n" "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";   
    sleep(2000);
    system("pause");   
    return 0;
}



I keep getting an error in line 7 known as line undeclared


1. You're not including the std namespaces to gain cout's function so for one you have to replace it with std::cout
2. Your Breaking your strings and putting a new string, either make it one full string or add << between strings (like i used for the first reply)
3. C++ is CASE SENSITIVE! the API's name is Sleep not sleep
4. Don't use system("pause"), you have so much else that you could use

std::cin.sync();
std::cin.ignore();
-------------------
(conio.h) _getch();
-------------------
(tchar.h) gettchar();
-------------------
etc.

Should Look like this

Code:
#include <iostream>
#include <windows.h>

int main()
{
     std::cout << "Hello User!" << " My name is JCoA\n" << "There are many things that I can help you with\n" <<  "I can do things such as: \n" << "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";
     Sleep(2000);
     std::cin.sync();
     std::cin.ignore();
     return 0;
}

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

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Mar 24, 2008 8:14 am    Post subject: Reply with quote

1. <iostream> not <iostream.h>
2. std::cout
3.
Code:
sleep(2000);
system("pause");


(also it should be Sleep, CAPITAL S)
is a gross way to do it, use this instead:
Code:

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


4. Your cout is all broken up needlessly, though I don't think it will really care. Why do things wrong when you can be right, though.

e: and I got the shit beat out of me because I didn't read the topic.
Back to top
View user's profile Send private message
XxOsirisxX
Grandmaster Cheater Supreme
Reputation: 0

Joined: 30 Oct 2006
Posts: 1597

PostPosted: Mon Mar 24, 2008 8:16 pm    Post subject: Reply with quote

lurc wrote:
Negima wrote:
Then why won't this work:

Code:
#include <iostream.h>
#include <windows.h>

int main(void)
{
    cout << "Hello User!" " My name is JCoA\n" "There are many things that I can help you with\n" "I can do things such as: \n" "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";   
    sleep(2000);
    system("pause");   
    return 0;
}



I keep getting an error in line 7 known as line undeclared


1. You're not including the std namespaces to gain cout's function so for one you have to replace it with std::cout
2. Your Breaking your strings and putting a new string, either make it one full string or add << between strings (like i used for the first reply)
3. C++ is CASE SENSITIVE! the API's name is Sleep not sleep
4. Don't use system("pause"), you have so much else that you could use

std::cin.sync();
std::cin.ignore();
-------------------
(conio.h) _getch();
-------------------
(tchar.h) gettchar();
-------------------
etc.

Should Look like this

Code:
#include <iostream>
#include <windows.h>

int main()
{
     std::cout << "Hello User!" << " My name is JCoA\n" << "There are many things that I can help you with\n" <<  "I can do things such as: \n" << "\n" "-Multiply\n" "-Divide\n" "-Add\n" "-Subtract\n";
     Sleep(2000);
     std::cin.sync();
     std::cin.ignore();
     return 0;
}


I did wonder why he did those strings "jump" i means, without the <<. But i did wanted to test, and the way he have it, works perfectly.

_________________

Back to top
View user's profile Send private message
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