New style (c to c++)
-
Hi Guys,
How to correct this to the new style?
int i, n = (int)strtol(argv[1], nullptr, 10); // here n = n/2; double s = strtod(argv[2], nullptr); double f = strtod(argv[3], nullptr); double a = tan(M_PI*f/s); double a2 = a*a; double r; double *A = (double *)malloc(n*sizeof(double)); //here double *d1 = (double *)malloc(n*sizeof(double)); //here double *d2 = (double *)malloc(n*sizeof(double)); //here double *w0 = (double *)calloc(n, sizeof(double)); //hereCheers
-
What do you mean with 'new style'? Do you mean using c++ (c++11/14/17) or Qt functions instead?
-
Hi Guys,
How to correct this to the new style?
int i, n = (int)strtol(argv[1], nullptr, 10); // here n = n/2; double s = strtod(argv[2], nullptr); double f = strtod(argv[3], nullptr); double a = tan(M_PI*f/s); double a2 = a*a; double r; double *A = (double *)malloc(n*sizeof(double)); //here double *d1 = (double *)malloc(n*sizeof(double)); //here double *d2 = (double *)malloc(n*sizeof(double)); //here double *w0 = (double *)calloc(n, sizeof(double)); //hereCheers
@pedromenezes said in New style:
int i, n = (int)strtol(argv[1], nullptr, 10); // hereUse
QString::toInt()orQByteArray::toInt()double *A = (double *)malloc(n*sizeof(double)); //here double *d1 = (double *)malloc(n*sizeof(double)); //here double *d2 = (double *)malloc(n*sizeof(double)); //here double *w0 = (double *)calloc(n, sizeof(double)); //hereUse
QVector<double>orstd::vector<double> -
What do you mean with 'new style'? Do you mean using c++ (c++11/14/17) or Qt functions instead?
@Christian-Ehrlicher Sorry, I mean c to c++.
-
@pedromenezes said in New style:
int i, n = (int)strtol(argv[1], nullptr, 10); // hereUse
QString::toInt()orQByteArray::toInt()double *A = (double *)malloc(n*sizeof(double)); //here double *d1 = (double *)malloc(n*sizeof(double)); //here double *d2 = (double *)malloc(n*sizeof(double)); //here double *w0 = (double *)calloc(n, sizeof(double)); //hereUse
QVector<double>orstd::vector<double>@JKSH thank you!! Problem solved!