New with C...need help!!
Hi, I'm really new to C programming and I don't know the answers to a few practice exam questions that the teacher provided for us to review with. If anyone could help me out that would wonderful :-) thank you!
1) Which of the following would be passed by address without the use of the address operator?
A. An array of structures
B. A single structure
C. Any element of a structure.
D. None of the Above
I think it is A...not at all sure though
2) Given a string, str1, with a size of SIZE, where would you find the delimiter after the user inputs a value that does not exceed the size of the array?
b. SIZE -1
D.None of the above
I think this one is C, but i thought the delimiter would be after the last value of the string?
for #1 you are correct--arrays are passed by reference. the address of the array is passed, not the entire array contents.
for #2 i would say b. say we have an array of 10 characters (SIZE = 10). we can initialize the 'string' to "hi\0". if you then do strlen(str1) youll get 2, however the array can actually hold 10. writing to index 2 isnt out of bounds, index 10 is out of bounds (SIZE-1 = 9 isnt out of bounds).
Originally Posted by man strlen
A and C are the answers, I believe. Looks like you understand it.