Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C ++ pointer two third memory model     - Linux md5sum verify file integrity (Linux)

- Linux environment to build next Cocos2dx-3.3.1 (Linux)

- Linux SVN installation and configuration graphic tutorials (Server)

- To explore the caching mechanism for Android ListView (Programming)

- Java Collections Framework interfaces map (Programming)

- CentOS 6.x systems installation + NIC driver installation (Realtek PCIe GBE Family Controller for Linux) (Linux)

- Various sorting algorithms implemented in Python (Programming)

- Installation and Configuration rsync server under CentOS 6.3 (Server)

- Windows Remote Desktop Management CentOS 6.4 (Linux)

- Spring WebSocket Comments (Programming)

- Java Cookie Comments (Programming)

- Preps - Print within the specified range of IP addresses (Linux)

- OpenSUSE / Linux network configuration (Linux)

- GoldenGate for Oracle data consistency initializing (Database)

- Oracle 11g DataGuard service to start automatically (Database)

- Automatic and Manual Proxy Settings Switch GNOME Shell Extension Proxy Switcher Recommend (Linux)

- Configuration based on open source Lucene Java development environment (Server)

- The Concept and Semantics of Java Memory Model (Programming)

- Ubuntu 15.10 install the latest Arduino IDE 1.6.7 (Linux)

- Developing a Web server yourself (Server)

 
         
  C ++ pointer two third memory model
     
  Add Date : 2017-08-31      
         
       
         
  C ++ pointer two third memory model

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void main ()
{
    int i = 0, j = 0;
    char buf [100];
    char ** myarray = (char **) malloc (10 * sizeof (char *)); // int array [10]
    if (myarray == NULL)
    {
        return;
    }
    for (i = 0; i < 10; i ++)
    {
        myarray [i] = (char *) malloc (100 * sizeof (char)); // char buf [100];
        if (myarray [i] == NULL)
        {
            printf ( "ddddde \ n");
            return;
        }
        sprintf (myarray [i], "% d% d% d", i, i, i);
    }

    // Third memory model Print
    printf ( "Before sorting \ n");
    for (i = 0; i < 10; i ++)
    {
        printf ( "% s \ n", myarray [i]);
    }

    // Sort
    for (i = 0; i < 10; i ++)
    {
        for (j = i + 1; j < 10; j ++)
        {
            if (strcmp (myarray [i], myarray [j]) < 0)
            {
                strcpy (buf, myarray [i]);
                strcpy (myarray [i], myarray [j]);
                strcpy (myarray [j], buf);
            }
        }
    }

    // Third memory model Print
    printf ( "After sorting \ n");
    for (i = 0; i < 10; i ++)
    {
        printf ( "% s \ n", myarray [i]);
    }

    for (i = 0; i < 10; i ++)
    {
        free (myarray [i]);
    }
    if (myarray! = NULL)
    {
        free (myarray);
    }

    system ( "pause");
}

 

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int printfArr33 (char ** ArrayStr, int iNum)
{
    int i = 0;
    for (i = 0; i < iNum; i ++)
    {
        printf ( "% s \ n", ArrayStr [i]);
    }
    return 0;
}

int sortArrayStr03 (char ** ArrayStr, int iNum)
{
    int i = 0, j = 0;
    char * tmp = NULL;
    // Sort

    for (i = 0; i < iNum; i ++)
    {
        for (j = i + 1; j < iNum; j ++)
        {
            if (strcmp (ArrayStr [i], ArrayStr [j]) < 0)
            {
                tmp = ArrayStr [i];
                ArrayStr [i] = ArrayStr [j];
                ArrayStr [j] = tmp;
            }
        }
    }
    return 0;
}

void main ()
{
    int i = 0, j = 0;
    char buf [100];
    char ** myarray = (char **) malloc (10 * sizeof (char *)); // int array [10]
    if (myarray == NULL)
    {
        return;
    }
    for (i = 0; i < 10; i ++)
    {
        myarray [i] = (char *) malloc (100 * sizeof (char)); // char buf [100];
        if (myarray [i] == NULL)
        {
            printf ( "ddddde \ n");
            return;
        }
        sprintf (myarray [i], "% d% d% d", i, i, i);
    }

    // Third memory model Print
    printf ( "Before sorting \ n");
    printfArr33 (myarray, 10);

    sortArrayStr03 (myarray, 10);

    // Third memory model Print
    printf ( "After sorting \ n");
    printfArr33 (myarray, 10);

    for (i = 0; i < 10; i ++)
    {
        free (myarray [i]);
    }
    if (myarray! = NULL)
    {
        free (myarray);
    }

    system ( "pause");
}
     
         
       
         
  More:      
 
- The most commonly used Linux commands (Linux)
- RHEL / CentOS / Fedora Install Nagios 4.0.1 (Linux)
- Linux linux system security (Linux)
- How do you prevent other users from accessing your home directory in Linux (Linux)
- Linux configuration startup mount: fstab file (Linux)
- Ubuntu disable graphics card (Linux)
- General Linux interface server parameter tuning (Server)
- To setup Cocos2dx project under Ubuntu (Linux)
- Applications in Objective-C runtime mechanism (Programming)
- Lenovo Ultrabooks Ubuntu system can not open the wireless hardware switch solutions (Linux)
- Linux and Windows Security Topics (Linux)
- Shell Scripting Basics (Linux)
- Installation CD audio file extraction tool Flacon (Linux)
- Linux Command - ps: a snapshot of the current process (Linux)
- Using Java arrays implement sequential stack (Programming)
- IronPython and C # to interact (Programming)
- LNMP summary of the issues common 502 Bad Gateway (Server)
- Linux System Getting Started Learning: Using the Linux command line detected DVD burner name and write speeds (Linux)
- Schema snapshot rollback (Database)
- CentOS7 management of systemd (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.