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 


[Help C++] Inserting a Loop into a Text File

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Jul 21, 2007 8:57 pm    Post subject: [Help C++] Inserting a Loop into a Text File Reply with quote

well, i cant seem to take the loop information i get and stick it in the .txt

im using fstream I/O to write the file (ofstream)

this is CLR btw

this is the code snippet of the I/O im using

Code:
   ofstream myFile("specs.txt", ios::app);
   if (myFile.is_open())
   {
      myFile << "Starting Sum: " << ssum << "\nInterest: " << irst << "\n\n\n";
      myFile << "Day: " << ++day << "\nMoney: $" << ssum + (irst * day) << "\n\n";
      myFile.close();
   }
   else { cout << "Unable to open Text Document"; }


now the
Code:
"Day: " << ++day << "\nMoney: $" << ssum + (irst * day) << "\n\n";


is obviously the loop, but i cant seem to get the loop into the txt document.

all together the loop is:

Code:
      while (day > 365)
      {
         cout << "Day: " << ++day << "\nMoney: $" << ssum + (irst * day) << "\n\n";
      }


helps appreciated...

the program asks u for your starting sum, then the daily interest, then the loop is supposed to show everyday's money. but obviously the CLR box isnt big enough. so a .txt document is my only choice

Edit: oh yea, before i forget, is there a way to increase by percent in C++, ive searched around but have found nothing.

% = modules (remainder) so theres nothing else i can think of accept for maybe deviding the number by 100 then multiplying by the percent

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

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Sat Jul 21, 2007 11:00 pm    Post subject: Reply with quote

that works to me
Code:

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

using std::cin;
using std::cout;
using std::ofstream;

int main()
{
    int day = 0;
    int ssum;
    int irst;
   ofstream myFile("specs.txt", std::ios::app);
   cin >> ssum >> irst;
   if (myFile.is_open())
   {
      myFile << "Starting Sum: " << ssum << "\nInterest: " << irst << "\n\n\n";
      while (day < 365)
      {
         myFile << "Day: " << ++day << "\nMoney: $" << ssum + (irst * day) << "\n\n";
      }     
      myFile.close();
   }
   else { cout << "Unable to open Text Document"; }
   return 0;
}

_________________

ASM/C++ Coder
Project Speranza lead developer
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Jul 22, 2007 7:52 am    Post subject: Reply with quote

it sent everysingle (365) line of the loop into your text file?
_________________
Back to top
View user's profile Send private message
Robotex
Master Cheater
Reputation: 0

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Sun Jul 22, 2007 9:37 pm    Post subject: Reply with quote

yes, btw i think your problem was
while (day > 365)
wich is supposed to be
while (day < 365)
?

_________________

ASM/C++ Coder
Project Speranza lead developer
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jul 23, 2007 6:43 pm    Post subject: Reply with quote

well i feel like an idiot.... -.-

yea, i figured that out last night, i just never thot to try and make it go in the text file.

well. lock this plz.

_________________
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