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

题目内容 (请给出正确答案)

对于下面的程序 ifstream fin(c:\test.txt); if(fin) cout<<"ok"; else cout<<"wrong"; 对于if语句中的内容可以换为

A.fin.fail( ):

B.fin.bad( );

C.fin.good( );

D.fin.eof( );


参考答案

更多 “ 对于下面的程序 ifstream fin(c:\test.txt); if(fin) cout<<"ok"; else cout<<"wrong"; 对于if语句中的内容可以换为A.fin.fail( ):B.fin.bad( );C.fin.good( );D.fin.eof( ); ” 相关考题
考题 若磁盘上已存在某个文本文件,其全路径文件名为 d:\ncre\test.txt ,下列语句中不 能打开该文件的是A . ifstream file("d:\ncre\test.txt") ;B . ifstream file("d:\ncre\test.txt");C . ifstream file; file.open("d:\ncre\test.txt");D . ifstream* pFile=new ifstream("d:\ncre\test.txt");

考题 若语句: cout') 若语句: cout<<setfill('>')<<setw(5)<<3141512<<setw(5)<<"OK!"; 是程序中第一个输出语句,则输出结果是A.3141512>>OK!B.31415120K!>>C.414150K!>>D.31415>>OK!

考题 ( 16 )要建立文件流并打开当前目录下的文件 file.dat 用于输入,下列语句中错误的是A ) ifstream fin=ifstream.open ( "file.dat" ) ;B ) ifstream*fir.=new ifstream ( "file.dat" ) ;C ) ifstream fin; fin.open ( "file.dat" ) ;D ) ifstream *fin=new ifstream ( ) ; fin 一 open ( "file.dat" ) ;

考题 下面的程序的结果是main( ){int x=3,y=0, z=0;if(x=y+z)cout<<"* * * *";else cout<<"####";}A.有语法错误不能通过编译B.输出****C.可以通过编译,但是不能通过连接,因而不能运行D.输出####

考题 简单C++问题。 #includeiostream.hint main(){ int a; cout"请输入一个大于0的数:\n"; cina; if (judge(a)==0){ cout"\n是偶数。"; }else{ cout"\n是奇数。"; }}int judge(int s){ if(s%2==0) { return 0; }else{ return 1; }}上面的程序哪里错了啊?为啥不能编译成功?

考题 下列程序从保存整数的文本文件”c:Sample.dat”中依次取出每个数据并显示出来,同时统计并显示出所有数据的个数。程序划线处的表达式为______。include<stream.h>include<stdlib.h>void main( ){ifstream fin("c:Sample.dat",los::nocreate);if(! fin){cout<<"文件无法打开!"<<endl;exit(1);}int x,i=0;while(______){cout<<x<<"";i++;}fin.close( );cout<<endl<<"文件中所有整数个数:"<<i<<endl;}

考题 有如下程序:include include using namespace std;int main(){cout.fill(' 有如下程序:#include <iostream>#include <iomanip>using namespace std;int main(){cout.fill('*');cout<<left<<setw(4)<<123<< "OK"<<end1;return 0;}执行这个程序的输出结果是( )。A.123*OKB.123*OK**C.*123OKD.*123**OK

考题 对于下面的程序: ifstream fin(c:\test.txt) ; if(fin) cout < < "ok"; else cout < < "wrong"; if语句中的内容可以换为A.fin. fail( ) ;B.fin. bad( ) ;C.fin. good( ) ;D.fin. eof( ) ;

考题 若语句:cout') 若语句: cout<<seffill('>')<<setw(5)<<3141512<<sctw(5)<<"OK!"; 是程序中第1个输出语句,则输出结果是( )。A.3141512>>OK!B.31415120K!>>C.314150K!>>D.31415>>OK!

考题 以下程序的输出结果是()。includemain(){int m=5;if(m++>5)cout 以下程序的输出结果是( )。 #include<iostream.h> main() { int m=5; if(m++>5) cout<<m; else cout<<m--; }A.7B.6C.5D.4

考题 下面程序运行结果为( )。 main() { char c='a'; if('a'<c< ='z') cout<<"LOW"; else cout<<"UP"; }A.LOWB.UPC.LOWUPD.语句错误,编译不能通过

考题 若磁盘上已存全路径文件名为c:\ctest\test.txt的文件,下面语句中不能打开该文件的是( )。A.ifstream *pFile=new ifstream("c:\\ctest\\test.txt");B.ifstream file("c:\\ctest\\test.txt");C.ifstream file;file.open("c:\\ctest\\test.txt");D.ifstream file("c:\etest\test.txt");

考题 执行语句序列 ofstream outfile("data.dat"); if(…)cout<<"ok";else cout<<"fail"; 后,如果文件打开成功,显示“ok”,否则显示“fail”。由此可知,上面if语句的“…” 处的表达式是A.outfile.fail()或outfileB.outfile.good()或!outfileC.outfile.good()或outfileD.outfile.fail()或!outfile

考题 下面程序的输出是 main() {int x=100, a=10, b=20, ok1=5, ok2=0; if(a<b) if(b! =15) if( ! ok1) else if(ok2) x= 10 x=-1 cout<<x<<end1; }A.-1B.0C.1D.不确定的值

考题 要建立文件流并打开当前目录下的文件file.dat用于输入,下列语句中错误的是A.ifstream fin=ifstream.open(”file.dat”);B.ifstream*fin=new ifstream(”file.dat”);C.ifstream fin;fin.open(”file.dat”);D.ifstream*fin=new ifstream();fin-open(”file.dat”);

考题 要建立文件流并打开当前目录下的文件6le.dat用于输入,下列语句中错误的是( )。A.ifstream fin=ffstream.open(”file.dat”);B.ifstream*fin=new ifstream(”file.dat”);C.ifstream fin;fin.open(”file.dat”);D.ifstream*fin=new ifstream;fin-open(”file.dat”);

考题 阅读下面的程序:includevoid main(){ int x; cin>>x; if(x++>5) cout 阅读下面的程序: #include<iostream.h> void main() { int x; cin>>x; if(x++>5) cout<<x<<endl; else cout<<x——<<endl; } 如果两次执行上述程序,且键盘输入分别为4和6,则输出结果分别是( )。A.4,6B.3,6C.4,7D.5,7

考题 若磁盘上已存在某个文本文件,其全路径文件名为d:\ncre\test.txt,下列语句中不能打开该文件的是A.ifstream file("d:\ncre\test.txt");B.ifstream file("d:\\ncre\\test.txt");C.ifstream file;file.open("d:\\ncre\\test.txt");D.ifstream* pFile=new ifstream("d:\\ncre\\test.txt");

考题 有如下程序: include include using namespace std; int ma 有如下程序: #include <iostream> #include <iomanip> using namespace std; int main() { cout.fill('*'); cout << left << setw(4) << 123 << "OK" << endl; return 0; }A.123*OKB.123*OK**C.*123OKD.*123**OK

考题 若磁盘上已存在某个文本文件,其全路径文件名为d:\shiti\tes.txt,下列语句中不能打开该文件的是( )。A.ifstream file("d:\shiti\test.txt");B.ifstream file("d:\\shiti\\test.txt");C.ifstream file;file.open("d:\\shiti\\test.txt");D.ifstream* pFile = new ifstream("d:\\shiti\\test.txt");

考题 执行下列语句序列后, ofstream outfile("DATA.DATA") if(…)cout<<"OK";else cout<<"FAIL";如果文件打开成功显示OK,否则就显示FAIL。由此可知,…处的表达式应是( )。A.outfile.fail()或outfileB.outfile.fail()或! outfileC.outfile.good()或outfileD.outfile.goodl()或! outfile

考题 对于下面的程序,说法正确的是 include void main( ) {int x=3,y=4,z=2; i 对于下面的程序,说法正确的是 #include<iostream.h> void main( ) { int x=3,y=4,z=2; if(X=y+z) cout <<"x=y+Z"; else cout<<"x!=y+Z";}A.不能通过编译B.输出6C.输出x! =y+zD.输出x=y+z

考题 当需要打开A盘上的abc.txt 文件用于输入时,则定义文件流对象的语句为______ 。A.fstream fin(“A: abc.txt”);B.ofstream fin (“A: abc.txt”);C.ifstream fin(“A: abc.txt”,ios:: app);D.ifstream fin(“A: abc.txt”,ios:: nocreate);

考题 对于下面的程序 ifstream fin(C:\test.tXt); if(fin) cout<<"ok"; else cout<<"wrong"; 对于if语句中的内容可以换为A.fin.fail() ;B.fin.bad() ;C.fin,good() ;D.fin.eof();

考题 下列语句不能够用于打开C根目录下文件test.txt的语句是( )A.ifstream fin;fin.open(″C:\\\\test.txt″); B.ifstream fin(″C:\\\\test.txt″); C.A和B D.ifstream fin;fin(″C:\\\\test.txt″);

考题 单选题要建立文件流并打开当前目录下的文件file.dat用于输入,下列语句中错误的是(  )。A ifstream fin=ifstream.open(“file.dat”);B ifstream* fin=new ifstream(“file.dat”);C ifstream fin; fin.open(“file.dat”);D ifstream* fin=new ifstream(); fin-open(“file.dat”);

考题 单选题若目前D盘根目录下并不存在test.txt文件,则下列打开文件方式不会自动创建test.txt文件的是(  )。A ifstream fin;fin.open(“d:\\test.txt”,ios_base::in);B fstmam fin;fin.open(“d:\\test.txt”,ios_base::out);C ofstream fout;fout.open(“d:\\test.txt”,ios_base::out);D ofstream fout;fout.open(“d:\\test.txt”,ios_base::app);