下列说明const chr* ptr;中,ptr应该是【 】。
第1题:
【单选题】设有以下说明语句: char sl[20]="hello",s2[20]="china";const char *ptr=s1; 以下语句中不符合C++语法规则的语句是 。
A.strcpy(s2,ptr);
B.ptr=s2;
C.ptr=ptr+4;
D.*ptr=*s2;
第2题:
下列程序的输出结果是 #include <iostream> using namespace std; int main () { char a [] = "Hello,World": char*ptr = a; while (*ptr) { if(*ptr>= 'a' &&*ptr <='z' cout<<char{*ptr+'A'-'a'); else cout<<*ptr; ptr++; } return 0; }
A. HELLO. WORLD
B. Hello, World
C. hELLO, wORLD
D. hello, world
第3题:
下列程序的输出结果是( )。 #include<iostream> using namespace std; int main() { char a[]=""Hello,World"; char*ptr = a; while(*ptr) { if(*ptr>= 'a' &&*ptr<='z') cout<<char(*ptr+'A'-'a'); else cout<<*ptr; ptr++; } retur 0; }
A.HELLO, WORLD
B.Hello, World
C.HELLO, world
D.hello, world
第4题:
在说明int const *ptr;中,ptr应是( )。
A.指向常量的指针
B.指针常量
C.指针常数
D.常指针
第5题:
下列有关指针的用法中错误的是( )。
A.int i;int*ptr=&i;
B.int i;int*ptr;i=*ptr;
C.int*ptr;ptr=0;
D.int i=5;int*ptr;*ptr&i;
第6题:
在整型指针变量ptr1、ptr12的定义中,错误的是 ______。
A.int x, *ptr1, ptr2;
B.int*ptrl, x, *ptr2;
C.int x,*ptrl=&x,*ptr2;
D.int*ptr1, x,*ptr2=&x;
第7题:
下列有关指针的用法中错误的是( )。
A.int i;int *ptr=&i;
B.inti;int *ptr;i=*ptr;
C.int *ptr;ptr=0;
D.int i=5;int *ptr;*ptr&i;
第8题:
下列程序的输出结果是______。 #include<iostream> using namespace std; int main() { char a []="Hello, World"; char *ptr=a; while (* ptr) { if(*ptr)= 'a'&& *ptr' <= 'z') cout << char(*ptr+'A'-'a'); else cout << *ptr; ptr++; } return 0; }
A.HELLO,WORLD
B.Hello,World
C.hELLO, wORLD
D.hello,world
第9题:
main函数中发生编译错误的语句是______。
include<iostream.h>
class A
{
public:
int a;
const int b;
A( ):a(10),b(20){}
void fun( )const
{
cout<<"a="<<a<<"\tb="<<b<<endl;
}
};
void main( )
{
A obj1;
const A*ptr=new A;
ptr=&obj1;
ptr->a=100;
ptr->fun( );
}