Click here to Skip to main content
12,820,857 members (31,335 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++/CLI

im trying to make a program that will only run for 50 times.
here's the sample of my code


string str = parse.get <std::string>("Trial.Value");
    int i;
    stringstream(str) >> i;
    if(i >= 51){

    int a = i + 1;    // problem here is it can only work once, after that it will                  
                      //stop adding. so im stuck with Value=2
    stringstream ss;
    ss << a;
    ofstream file("config.ini");
    file << "[Trial]";
    file << "\nValue=";
    file << (ss, ios::ate); //problem here (i think) matter what value i put
                            // in sample.ini for example Value=25 ...the output 
                            //will still be Value=2


what i want to do here is every time i will open this program it will add +1 in Value=1 until it reaches Value=50..please any way to do this?

thanks in advance
Posted 19-Aug-12 11:23am
Updated 19-Aug-12 11:33am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Clearly, this is not a hard scheme to crack. Given that you don't read it as an ini file, why not write a random stream of bytes, and come up with a way that the content all changes, so no-one can tell which byte is the one you're reading ( for example, use a hash and encode your sequence somehow so that it's not 1-50, for example if you create a random number generated with a hard coded seed, you can reproduce that sequence to count to what the 50th value is ).

I don't know off hand why this is not working, but if you change your code to something that might actually survive attempts to crack it, along the way you will probably find that you'll write something that works.
Sergey Alexandrovich Kryukov 19-Aug-12 23:00pm
Fair enough, my 5.
And I think the scheme devised by OP is just a pretty bad idea...
Juan _dela_cruz 20-Aug-12 0:25am
thank you sir.. i just want to try to start from this(its just an example anyway)..yes i really plan to make it hard to crack..thanks again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170308.1 | Last Updated 19 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100