char txt [20] = "Hello world!\0";
a) 11 bytes
b) 12 bytes
c) 13 bytes
d) 20 bytes
e) 21 bytes
Sunday, January 10, 2010
In terms of code generation, how do the two definitions of buf, both presented above, differ?
char buf [] = "Hello world!";
char * buf = "Hello world!";
a) The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not
b) The first definition is not suitable for usage as an argument to a function call; the second definition is
c) The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal
d) They do not differ -- they are functionally equivalent
e) The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does
char * buf = "Hello world!";
a) The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not
b) The first definition is not suitable for usage as an argument to a function call; the second definition is
c) The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal
d) They do not differ -- they are functionally equivalent
e) The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does
Which one of the following will declare a pointer to an integer at address 0x200 in memory?
a) int *x;
*x = 0x200;
b) int *x = &0x200;
c) int *x = *0x200;
d) int *x = 0x200;
e) int *x( &0x200 );
*x = 0x200;
b) int *x = &0x200;
c) int *x = *0x200;
d) int *x = 0x200;
e) int *x( &0x200 );
What string does ptr point to in the sample code below?
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
a) fg
b) efg
c) defg
d) cdefg
e) None of the above
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;
a) fg
b) efg
c) defg
d) cdefg
e) None of the above
What value will x contain when the sample code below is executed?
int x = 3;
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
a) 1
b) 2
c) 3
d) 4
e) 5
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
a) 1
b) 2
c) 3
d) 4
e) 5
Subscribe to:
Posts (Atom)