string 字符串首字母转换为大写&&数组基本操作

#include <iostream>//IO输入输出流相关
#include <string>//C++
#include <cstring>//C
#include <cstddef>//size_t
#include <vector>//内置模版容器

using namespace std;//命名空间

int main()
{
    string s("John_Tian 2013.9.3");
	cout<<s<<endl;//输出原始字符串

	string::iterator it=s.begin();
	 //convert first word in s to uppercase
	 while (it!=s.end()&&!isspace(*it))//isspace()判断是否为空格
	 {
		 *it=toupper(*it);//toupper把对应字母变换为大写
		 ++it;
	 }
	 cout<<s<<endl;//输出首写字母转换后字符串

	 const size_t array_size=5;//数组大小常量,类型为const size_t
	 int a[array_size]={0,1,2,3,4};

	 for (size_t ix=0;ix!=array_size;++ix)//前置++
	 {
		 cout<<a[ix]<<endl;
	 }
     cout<<"①"<<endl;
	 for (size_t iy=0;iy!=array_size;iy++)//后置++
	 {
		 cout<<a[iy]<<endl;
	 }
     cout<<"②"<<endl;
	 return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Digital2Slave

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值