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 


First little C++ Program

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries
View previous topic :: View next topic  
Author Message
Evil_Intentions
Expert Cheater
Reputation: 65

Joined: 07 Jan 2010
Posts: 214

PostPosted: Wed Jun 02, 2010 10:49 pm    Post subject: First little C++ Program Reply with quote

Here is a Fibonacci sequence generator that i made. It will create a perfectly accurate sequence no matter the length.

http://www.mediafire.com/?rzqnzynzm4u

Unzip the folder and run the program. it will ask how long of a sequence you wish to make. I don't recommend going over a million, it may take a while, but 10k should only take around 30 seconds are so. After the program is finished, a .rtf file will be created in the same folder as the program, you can open it to view your sequence.

I need testers, because I'm not sure if it is working right, so i used a different compiler.

Please report any errors.

Also, this is only my 3rd or so c++ program, i just started last week, so constructive criticism is always good Very Happy

SOURCE:
Code:
#include <NTL/ZZ.h>
#include <fstream>
NTL_CLIENT



int main()
{

   system("cls");
   ZZ count;
   ZZ first;
   ZZ second;
   ZZ third;

   ofstream myfile;
   myfile.open("Fib_Sequencce.rtf");


   system("title Fibonacci");
   system("color 4");
   cout << "Please insert how many iterations you want: ";
   cin >> count;

   first=0;
   second=1;
   third=0;

   system("cls");
   cout << "Working...Please do not close the window.";
   myfile  << first << "\n" << second << "\n";




   while (count >0)
   {
      third=first + second;
      first=second;
      second=third;

      myfile << fixed << third << "\n";
      count=count-1;

   }
   system("cls");
   cout << "Finished!, please check the folder for your file.\n\n";
   cin.get();
   return 0;

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

Joined: 25 Jun 2007
Posts: 695

PostPosted: Thu Jun 03, 2010 1:48 am    Post subject: Reply with quote

Expect a "system"-usage speech from one of the senior programmers.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Jun 03, 2010 2:18 am    Post subject: Reply with quote

nwongfeiying wrote:
Expect a "system"-usage speech from one of the senior programmers.


Blah blah blah.

TL;DR - Don't use system. Ever. I will gouge your eyes out.
Back to top
View user's profile Send private message
Evil_Intentions
Expert Cheater
Reputation: 65

Joined: 07 Jan 2010
Posts: 214

PostPosted: Thu Jun 03, 2010 2:49 am    Post subject: Reply with quote

Flyte wrote:
nwongfeiying wrote:
Expect a "system"-usage speech from one of the senior programmers.


Blah blah blah.

TL;DR - Don't use system. Ever. I will gouge your eyes out.


GAH...i sorry, i just started a few days ago.... is there something like, "cout.clear()" or anything similar?

And what is so bad about using "system" anyway? Some of the best c++ books use it.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Jun 03, 2010 3:22 am    Post subject: Reply with quote

Evil Intentions wrote:
GAH...i sorry, i just started a few days ago.... is there something like, "cout.clear()" or anything similar?

And what is so bad about using "system" anyway? Some of the best c++ books use it.


There is no need to apologize. It's a common mistake for people learning.

'system()' calls are bad like 'goto' is bad. It promotes bad programming practices. If a C++ book uses it chances are it's crap.
Back to top
View user's profile Send private message
Evil_Intentions
Expert Cheater
Reputation: 65

Joined: 07 Jan 2010
Posts: 214

PostPosted: Thu Jun 03, 2010 4:51 am    Post subject: Reply with quote

Flyte wrote:
Evil Intentions wrote:
GAH...i sorry, i just started a few days ago.... is there something like, "cout.clear()" or anything similar?

And what is so bad about using "system" anyway? Some of the best c++ books use it.


There is no need to apologize. It's a common mistake for people learning.

'system()' calls are bad like 'goto' is bad. It promotes bad programming practices. If a C++ book uses it chances are it's crap.


O.o then you RREEEALLYYY don't want to see my FIRST program. lots of gotos and system calls ^^
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Jun 03, 2010 4:57 am    Post subject: Reply with quote

Then u should try avoiding that command
this isn't c programming it's more batch

_________________
Stylo
Back to top
View user's profile Send private message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Fri Jun 04, 2010 9:01 am    Post subject: Reply with quote

you should use

GetChar();

Btw, if ur book use goto statements, its a little bit old
Back to top
View user's profile Send private message
Evil_Intentions
Expert Cheater
Reputation: 65

Joined: 07 Jan 2010
Posts: 214

PostPosted: Fri Jun 04, 2010 3:46 pm    Post subject: Reply with quote

NoMercy wrote:
you should use

GetChar();

Btw, if ur book use goto statements, its a little bit old


Let me rephrase, the book i use has system calls in the beginning chapter. it introduces other ways later. I just havn't read enough.

and no the book doesn't use goto at all, its just something i remembered from by vbscript and batch days.
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 -> Binaries 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