Bitcoin Forum
June 04, 2024, 12:26:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Need guidance from C++ programmers  (Read 737 times)
pandalion98 (OP)
Sr. Member
****
Offline Offline

Activity: 504
Merit: 250



View Profile WWW
August 25, 2014, 11:14:34 AM
 #1

This is my code:
Code:
#include <iostream>
#include <iomanip>
#include "sha256.h"
#include <string>
#include <sstream>
using namespace std;

int main()
{
   int a = 0;
   int b = 1;
   int h = 0;
   string j = "80";

   do
   {
        h++;
        cout << j << hex << setfill('0') << setw(64) << h << endl;

   }
   while ( a < b );
   return 0;
   }
The code does this:
1. It increments the variable "h" by 1
2. Adds the 000000000000000000 padding that I need
3. converts it to hex
4. appends the 0x80 (See here: https://en.bitcoin.it/wiki/Wallet_import_format)

How do I transfer the output to another variable instead of just using cout?
iluvpie60
Hero Member
*****
Offline Offline

Activity: 700
Merit: 500


View Profile
August 25, 2014, 12:47:25 PM
 #2

This is my code:
Code:
#include <iostream>
#include <iomanip>
#include "sha256.h"
#include <string>
#include <sstream>
using namespace std;

int main()
{
   int a = 0;
   int b = 1;
   int h = 0;
   string j = "80";

   do
   {
        h++;
        cout << j << hex << setfill('0') << setw(64) << h << endl;

   }
   while ( a < b );
   return 0;
   }
The code does this:
1. It increments the variable "h" by 1
2. Adds the 000000000000000000 padding that I need
3. converts it to hex
4. appends the 0x80 (See here: https://en.bitcoin.it/wiki/Wallet_import_format)

How do I transfer the output to another variable instead of just using cout?

why don't you just throw whatever the result is into a temporary variable?

so the output variable would be C, then each time the loop runs have something increment C so you can have a count, so you can have it output like C1 = blah129832392 C2= b1293029301923 C3= 023940349fj2

are you talking about like that?

if this is all just outputting to a console, i would recommend you output into a database and preferably not a text document but you can.
pandalion98 (OP)
Sr. Member
****
Offline Offline

Activity: 504
Merit: 250



View Profile WWW
August 25, 2014, 12:56:48 PM
 #3


why don't you just throw whatever the result is into a temporary variable?

so the output variable would be C, then each time the loop runs have something increment C so you can have a count, so you can have it output like C1 = blah129832392 C2= b1293029301923 C3= 023940349fj2

are you talking about like that?

if this is all just outputting to a console, i would recommend you output into a database and preferably not a text document but you can.

I figured it out using stringstream. Will post back with updates tomorrow.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!