全文预览

C++程序设计语言-习题解答及综合实验讲义_第二版_.pdf

上传者:蓝天 |  格式:pdf  |  页数:204 |  大小:0KB

文档介绍
”; What is the length of the string “a short string”? #include <iostream> #include <cstring> using namespace std; int main() { char str[] = "a short string" ; cout<< sizeof (str)<<endl; cout<<strlen(str)<<endl; return 0 ; } 7. Define a table of the names of months of the year and the number of days in each month. Write out that table. Do this twice; once using an array of char for the names and an array for the number of days and once using an array of structures, with each structure holding the name of a month and the number of days in it. #include <iostream> #include <string> using namespace std; char *months_of_year[ 13] = { "" ,"January" ,"February" ,"Match" ,"April" ,"May" , "June" ,"July" ,"Auguest" ,"September" ,"October" ,"November" ,"December" };

收藏

分享

举报
下载此文档