zoukankan      html  css  js  c++  java
  • 指针和字符串

    #define _CRT_SECURE_NO_WARNINGS
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<math.h>
    #include<time.h>

    int main01()

    {

      /*char  ch[]="hello world";

      char*p=ch;

      printf("%s ",p);//hello world

      printf("%c ",*p);//h

      printf("%c ",*(p+1));//e */

      char ch[]="hello world";//栈区字符串

      char*p="hello world";//数据区常量区字符串

      char*p1="hello world";

    //内存地址相同

      printf("%p ",p);

      printf("%p ",p1);

      

      ch[2]='m';

      //*(p+2)='m';//err

      //p[2]='m';//err

      printf("%s ",ch);//hemlo world

      printf("%s ",p);//hello world

      return EXIT_SUCCESS;

    }

     

    int mani(void)

    {

    //字符串数组

    //指针数组   int*arr[3];

    //可修改

      /*char ch1[]="hello";

      char ch2[]="world";

      char ch3[]="aoligei";

      char*arr[]={ch1,ch2,ch3};*/

      

    //字符串数组;常量字符串,不能修改

      char*arr[]={"hello","world","aoligei"};

      /*for(int i=0;i<3;i++)

      {

        printf("%s ",arr[i]);//hello world aoligei

        printf("%c ",arr[i][0]);//h  w  a

      }*/

      

    //字符串排序(根据字符串首字母ASCII码)

      for(int i=0;i<3-1;i++)

      {

        for(int j=0;j<3-1-i;j++)

        {

          if(arr[j][0]>arr[j+1][0])

          {

            chat*temp=arr[j];

            arr[j]=arr[j+1];

            arr[j+1]=temp;

          }

        }

      }

      for(int i=0;i<3;i++)

      {

        printf("%s ",arr[i]);

      }

      return 0;

    }

  • 相关阅读:
    mysql "The user specified as a definer ('root'@'%') does not exist" 问题
    mysql添加Federated引擎问题
    D7经典脚本[multi/handler]
    redhat7.4安装vertica-9.1.0教程
    批量在当前目录下所有的文件中添加指定字段
    mysql 水平分表技术
    linux普通用户提权
    两步完成利用procdump64+mimikatz获取win用户密码
    hibernate中对象的三种状态分析
    Hibernate 入门案例
  • 原文地址:https://www.cnblogs.com/wanghong19991213/p/13586582.html
Copyright © 2011-2022 走看看