zoukankan      html  css  js  c++  java
  • 定义一个字符数组并初始化,然后输出其中字符串

     1 #include<iostream>
     2 using namespace std;
     3 int main(){
     4     char str[]="やはり俺の青春ラブコメは間違い";
     5     cout<<str<<endl;
     6     int a[8]={1,864,89,46,48,35,24};
     7     for(int i=0;i<8;i++){
     8         cout<<a[i]<<endl;
     9     }
    10 }

    定义一个字符串变量并初始化,输出

    #include<iostream>
    using namespace std;
    int main(){
    	string str="asd nsn dao";
    	cout<<str<<endl;
    
    }
    

      

    指向字符串的字符指针

    #include<iostream>
    using namespace std;
    int main(){
    	char *str="asd nsn dao";
    	cout<<str<<endl;
    
    }
    

      

    #include<iostream>
    #include <string.h>
    using namespace std;
    int main(){
        char str[]="asd nsn dao";
        char str2[]={9,8,24};
        strcpy(str2,str);
        cout<<str2<<endl;
    
    }

  • 相关阅读:
    pop指令的执行过程
    ipad 4.2 开发环境
    XP远程桌面
    停机问题、哥德尔定理
    看MIT的线性代数
    VizA项目继续推进
    port systemc to mac os x
    关于jar
    普桑
    拉突爾
  • 原文地址:https://www.cnblogs.com/sanyeai/p/8052674.html
Copyright © 2011-2022 走看看