文字と文字列

under construction …

#include <iostream>
 
using std::cout;
using std::cin;
using std::endl;
 
int main()
{
	//文字型を弄る
	char w0 = 'a',w1='c',w2='f'; //シングルクォートでアスキーコード番号を代入
	char w3 = 0x61 , w4 = 0x63 , w5 = 0x66;
 
	cout << w0 << endl;
	cout << w1 << endl;
	cout << w2 << endl;
	cout << w3 << endl;
	cout << w4 << endl;
	cout << w5 << endl;
	//0x41 => 'A'
	for (char i = 0x41; i < 0x41 + 26; i++)
	{
		cout << i;
	}
	cout << endl;
	//97=0x61 => 'a'
	//for(char i= 'a';でもいけるよ!
	for (char i = 97; i < 97 + 26; i++)
	{
		cout << i;
	}
	cout << endl;
	//文字列 "hello"
	//文字配列 char型の配列 + '\0' ←ナル文字(終端文字)
	//char str1[6] = { 'h','e','l','l','o','\0' };
	char str1[] = "hello";
	//cout << str1 << endl;
	//"hello, world!" をstr1を使って作るにはどうしたらいいかなぁ
	char str3[] = ", world!";
	char str2[14];
	for (int i = 0; i < 14; i++)
	{
		if (i < 5) {
			str2[i] = str1[i];
		}
		else
		{
			str2[i] = str3[i-5];
		}
	}
	cout << str2 << endl;
 
}