#include "HTC_header.h"


 void initialization_h(struct particle *particle,struct machine *machine)
 {
    int i,t;
    double rnd;
    for (i=0;i<mh;i++)
    {
        for (t=0;t<tym;t++)      
        {
            rnd=((double) rand() / RAND_MAX);
            particle->qh[t][i]= machine->qmin[i]+(rnd*(machine->qmax[i]- machine->qmin[i]));
        }
    }


 }  // end of func

That's already C++. You could improve it by removing the struct keywords, passing references instead of pointers, not using mh and tym (ugly global variables), making your particle and machine types use proper C++ containers (which know their own size) instead of arrays, and using a modern C++11 random number generator instead of the truly awful rand() function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.