Before i start i would like to say that i am a complete beginner when it comes to c++, but i am familiar with other programming languages.
I am attempting to write a code that will take a string, and hash it X number of times.
Pseudo code:
Times to hash = X
String to hash = "Hello world"
For i=1 to 10
   hash string
next
Console write string that has been hashed X times.
I have done some research and i have modified this code, but the problem is the hash algorithm is md5 and i would like it to be sha256 (but i couldn't find an useful code i could adapt)
#include "md5.h"
#include <string>
#include <iostream>
using namespace std;
int main()
{
  MD5 md5 ;
  string str1(md5.digestString( "String" ));
  cout << str1;
  return 0;
}
I have had look a several for loops but i can seem to get any of them to work but here is on of my attempts:
int i = 0;
for (; i<50; ++i) {
    cout << "Hello world";
}
The error for the for loop:
2   1   C:\Users\09stephenb\Desktop\Hash.cpp    [Error] expected unqualified-id before 'for'
2   8   C:\Users\09stephenb\Desktop\Hash.cpp    [Error] 'i' does not name a type
2   14  C:\Users\09stephenb\Desktop\Hash.cpp    [Error] expected unqualified-id before '++' token
But im getting errors like "i is not a type", im assuming variable type, but im not quite sure what to do next.
I am somewhat reluctant to learn C++ fully at this time as this is just a tiny section of the project that i am working on.
Edit
Form the comments and answers i have this code:
#include <iostream>
#include "md5.h"
#include <string>
using namespace std;
int main() {
    int count = 50;
    std::string prev = "stringtohash";
    std::string cur;
    
    for(int i=0; i < count; ++i) {
        cur = md5.digestString(prev);
        prev = cur;
    }
    
    std::cout << cur;
    return 0;
}
But it returns the error: [Error] 'md5' was not declared in this scope
Any help would be greatly appreciated.
 
     
     
    