char name[16] = "abcdefg"; //输出结果是多少? cout << name << endl; name[3] = '\0'; //输出结果又是多少? cout << name << endl;
# include <iostream>
# include <cstring>
# define SIZE 15
using namespace std;
int main(void)
{
char name_cin[SIZE];
char name[SIZE] = "C++owboy"; //initialized array
cout << "Hello I'm " << name;
cout << "! What is your name ? ";
cin >> name_cin;
cout << "Well " << name_cin << ", your name has ";
cout << strlen(name_cin) << " letters and is stored " << endl;
cout << "in an array of " << sizeof(name_cin) << "bytes." << endl;
cout << "your initial is " << name_cin[0] << "." << endl;
name[3] = '\0';
cout << "Here are the first 3 characters of my name : ";
cout << name << endl;
return 0;
}
# include <iostream>
using namespace std;
int main(void)
{
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << "Enter your name : " << endl;
cin >> name; //输入名字
cout << "Enter your favorite dessert: " << endl;
cin >> dessert; //输入甜点的名字
cout << "I have some delicious " << dessert;
cout << " for you, " << name << "." << endl;
return 0;
}
# include <iostream>
using namespace std;
int main(void)
{
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << "Enter you name : " << endl;
cin.getline(name,ArSize);
cout << "Enter you favorite dessert : " << endl;
cin.getline(dessert,ArSize);
cout << "I have some delicious " << dessert;
cout << " for you," << name << endl;
return 0;
}
# include <iostream>
using namespace std;
int main(void)
{
cout << "What year was your house built? " << endl;
int year;
cin >> year;
//char ch;
//cin.get(ch); 接收换行符 (cin >> year).get();
cout << "What is its street address ? " << endl;
char address[80];
cin.getline(address, 80);
cout << "Year built : " << year << endl;
cout << "Address : " << address << endl;
cout << "Done ! " << endl;
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有