c风格字符串

#include <iostream>

#include <cstring>

using namespace std;

struct dd

{

    int a;double b;

};

struct aa

{

    dd t,q;

};

struct qq

{

    aa o;

};

int main()

{

    qq z[10];

    z[0].o.t.a=10;//结构体的嵌套格式





    std::ios::sync_with_stdio(false);//取消同步



    char

    greet[100]="\"""""""\"Hello \n\n\n\n\n\n\n\n\nworld!"

               "gjaoijodsmfsdmmmmmmmmmm";     //用""来换行接上一行





    //greet[80]='8';





    char s[100];

    cin.ignore(80,'\n');//从输入流中删除多余的字符    包括'\n'



    cin.getline(s,10,'3');//'3' can also be alternated by '@' 'a' **** And the default is' \n '



    cout << greet<<endl<<strlen(greet)<<endl;//strlen是读到第一个'\0' 为止   后面什么样不管



    cout <<s<<endl;





    char name1[7]="fucker";//name1[6]='1';   ←--------------┓

    char name2[10]="8";    //                               ┃

    strcpy(name2,name1);//name1 必须以'\n' 结束  如果这样---┚

    cout << name2<<endl;//name2="fucker"



    if (strcmp(name1,name2)==0) cout <<"Yes"<<endl;//如果两个字符串相等返回0  1>2返回值为正 1<2 为负



    //常用的还有      strncat(str1,str2,n)    

    //                strncpy(str1,str2,n)  



    //char s[]="123456";

    //int  t; t=atoi(s); 转换字符串为数值    atof转成小数   需包含 #include<cstdlib>



    return 0;

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值