Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. New style (c to c++)
Forum Updated to NodeBB v4.3 + New Features

New style (c to c++)

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 789 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pedromenezes
    wrote on last edited by pedromenezes
    #1

    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)); //here
    

    Cheers

    JKSHJ 1 Reply Last reply
    -1
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What do you mean with 'new style'? Do you mean using c++ (c++11/14/17) or Qt functions instead?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      P 1 Reply Last reply
      3
      • P pedromenezes

        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)); //here
        

        Cheers

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by JKSH
        #3

        @pedromenezes said in New style:

        int i, n = (int)strtol(argv[1], nullptr, 10); // here
        

        Use QString::toInt() or QByteArray::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)); //here
        

        Use QVector<double> or std::vector<double>

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        P 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          What do you mean with 'new style'? Do you mean using c++ (c++11/14/17) or Qt functions instead?

          P Offline
          P Offline
          pedromenezes
          wrote on last edited by
          #4

          @Christian-Ehrlicher Sorry, I mean c to c++.

          1 Reply Last reply
          0
          • JKSHJ JKSH

            @pedromenezes said in New style:

            int i, n = (int)strtol(argv[1], nullptr, 10); // here
            

            Use QString::toInt() or QByteArray::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)); //here
            

            Use QVector<double> or std::vector<double>

            P Offline
            P Offline
            pedromenezes
            wrote on last edited by
            #5

            @JKSH thank you!! Problem solved!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved