网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
这个c++程序中char city[20]; 的作用是什么 ?

#include <fstream>

#include <iostream>

using namespace std;

int main()

{

    fstream inout;

inout.open("city.txt",ios::out);

inout<<"Dallas"<<" "<<"tonghua"<<" "<<"长春"<<" " ;

inout.close();

inout.open("city.txt",ios::app | ios::out);

inout<<"罗马"<<" "<<"巴黎"<<" ";

inout.close();

char city[20];

inout.open("city.txt",ios::in);

while(!inout.eof())

{inout>>city;

cout<<city<<" ";

                 } 

                 inout.close();

                 

    system("PAUSE");

    return 0;

}


参考答案

更多 “ 这个c++程序中char city[20]; 的作用是什么 ? #includefstream#includeiostreamusingnamespacestd;intmain(){fstreaminout;inout.open("city.txt",ios::out);inout"Dallas""""tonghua""""长春""";inout.close();inout.open("city.txt",ios::app|ios::out);inout"罗马""""巴黎""";inout.close();charcity[20];inout.open("city.txt",ios::in);while(!inout.eof()){inoutcity;coutcity"";}inout.close();system("PAUSE");return0;} ” 相关考题
考题 创建S表时,SNo使用CHAR(5)并且唯一,SName使用CHAR(30),Status使用CHAR(8),City使用CHAR(20)。请在下列用于创建表S的SQL语句空缺处填入正确的内容。CREATE TABLE S(SNo CHAR(5),SName CHAR(30),Status CHAR(8),City CHAR(20),______;

考题 关于c++的问题 int*b= int x; x=*b;//这个x肯定是c的值 x=b;//这个x是什么?这么写对吗? coutb;//这个会出现什么?

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]本程序使用类来管理员工的通讯地址信息。已知程序的输出为:输出记录:5姓名:王丽华街道地址:中华路15号市:襄樊市省;湖北省邮政编码:430070[C++程序]include < iostream, h >include < string, h >class employee.{ protected:char name[10];char street[ 20 ];char city[10];char (1) [10];char post[7];int no;(2):(3) (char [] ,char [] ,char [] ,char [] ,char [] ,int);void changename ( char n [] ) { strcpy ( name, n); }void changestreet( char s[] ) { strcpy(street,s) ;}void changecity ( char c [] ) { strcpy ( city, c ); }void changeprov( char p [] ) { strcpy(prov,p); }void changeno(int nnm) { (4);}void display( );};employee:: (3) (char n[] ,char s[] ,char c[] ,char p1[] ,char p2[] ,int nam){ strcpy(name,n);strcpy ( street, s);strcpy ( city, c);strcpy ( prov, p1 );strcpy ( post, p2 );no = nam; }void employee:: display( ) { cont< <"输出记录: "< <no< <endl;cout< < "姓名: "< < name < < endl;coot < < "街道地址: "< < street < < endl;cout < < "市: "< < city < < endl;cout< <"省: "< <prov < <endl;cout < <"邮政编码: "< < post < < endl;}void main( ) { employee cmp("王华" ,"中华路15号" ,"武汉市","湖北省","430070", 1 );emp. changename( "五丽华" );emp. changecity ( "襄樊市" );emp. changeno(5);(5);

考题 有以下程序includemain(){ char*p,*q;p=(char *)malloc(sizeof(char)*20);q=p;scanf( 有以下程序 #include<stdlib.h> main() { char*p,*q; p=(char *)malloc(sizeof(char)*20);q=p; scanf(“%s%s”,p,q);printf(“%s%s\n”,p,q); } 若从键盘输入:abc def<回车>,则输出结果是A.def defB.abc defC.abc dD.d d

考题 有以下程序include main(){ char *p,*q;p=(char*)malloc(sizeof(char)*20);q=p;scanf 有以下程序 #include <stdlib.h> main() { char *p,*q; p=(char*)malloc(sizeof(char)*20); q=p; scanf("%s %s",p,q); printf("%s %s\n",p,q); } 若从键盘输入:abc def<回车>, 则输出结果是A.def defB.abc delC.abc dD.d d

考题 C++初学sizeof问题 char*p[]={"RobertRedford","HopalongCassidy","Lassle","SlinPickens","BorisKarloff","OlicerHardy"};char*pstart="Yourluckystaris";intcount=(sizeofp)/(sizeofp[0]);intdice=0;coutendl"Pickaluckystar!""Enteranumberbetween1and"cout":";cindice;coutendl;if(dice=1dice=count)coutpstartp[dice-1];elsecout"Sorry,youhaven'tgotaluckystar";coutendl;return0;这是从本书上看到的我想知道第三个语句中的count是什么?应该是算数组里有多少个数据可是这个语句算不出来吧这可是char型而且数组中每个数据长度都不一样我想知道这个count的表达式怎么写是对的?

考题 使用VC6打开考生文件夹下的工程test18_3,此工程包含一个源程序文件test18_3.cpp,其中定义了用于表示雇员的类 Employee,但类Employee的定义并不完整。请按要求完成下列操作,将类Employee的定义补充完整。(1)补充类Employee的构造函数,请使用字符串函数将数据成员name,address,city,province和zipcode分别初始化为参数*nm,*addr,*city,*prov和*zip的值。请在注释“//**1**”之后添加适当的语句;(2)完成类Employee的成员函数ChangeName(char * newName)的定义,将newName指向的内容赋值给数据成员name,请在注释“//**2**”之后添加适当的语句;(3)完成类Employee的成员函数Display()的定义,先使用指针buffer动态申请一个char型的200单位大小的空间,然后使用字符串函数将数据成员name和address依次复制其中,最后返回该指针buffer,将请在注释“//**3**”之后添加适当的语句。输出结果如下:王东建国路大街105号注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test18_3.cpp清单如下:include <iostream.h>include <string.h>class Employee{protected:char name[20];char address[100];char city[20];char province[20];char zipcode[10];public:Employee(char *nm, char *addr,char *city, char *prov, char *zip);void ChangeName(char *newName);char *Display();};Employee::Employee(char *nm, char *adr, char *cit, char *prov, char *zip){//**1**strcpy(city, cit);strcpy(province,prov);strcpy(zipcode,zip);}void Employee::ChangeName(char * newName){//**2**}char *Employee::Display(){//**3**strcat(buffer, address);return buffer;}void main(){Employee emp("李华","建国路大街105号","石家庄","河北","103400");emp. ChangeName ("王东");cout<<emp.Display()<<end1;}

考题 有以下程序,程序运行的结果是 ______。includeincludevoid main(){charx 有以下程序,程序运行的结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char x[]= "C++" ,y[10]= "C++" ; cout<<sizeof(x)/sizeof(char)<<“,”<<sizeof(y)/sizeof(char); }A.3 3B.4 4C.4 10D.10 10

考题 (29)有以下程序include stdio.hvoid fun(char *c){ while(*c){ if(*c='a'stdio.hvoid fun(char *c){ while(*c){ if(*c='a'*c='z') *c=*c-('a'-'A');c++;}}main(){ char s[81];gets(s); fun(s); puts(s):}当执行程序时从键盘上输入Hello Beijing回车,则程序的输出结果是A)hello beijingB)Hello BeijingC)HELLO BEIJINGD)hELLO Beijing