About GBdirect Consultancy Training Development

Section navigation

Leeds Office (National HQ)

GBdirect Ltd
Leeds Innovation Centre
103 Clarendon Road
LEEDS
LS2 9DF
West Yorkshire
United Kingdom

consulting@gbdirect.co.uk

tel: +44 (0)870 200 7273
Sales: 0800 651 0338

South East Regional Office

GBdirect Ltd
18 Lynn Rd
ELY
CB6 1DA
Cambridgeshire
United Kingdom

consulting@gbdirect.co.uk

tel: +44 (0)870 200 7273
Sales: 0800 651 0338

Please note: Initial enquiries should always be directed to our UK national office in Leeds (West Yorkshire), even if the enquiry concerns services delivered in London or South/East England. Clients in London and the South East will typically be handled by staff working in the London or Cambridge areas.

5.10. Exercises

Exercise 5.1. What is the valid range of indices for an array of ten objects?

Exercise 5.2. What happens if you take the address of the 11th member of that array?

Exercise 5.3. When is it valid to compare the values of two pointers?

Exercise 5.4. What is the use of a pointer to void?

Exercise 5.5. Write functions which:

  1. Compare two strings for equality. If they are equal, zero is returned, otherwise the difference in value between the first two non-matching characters.
  2. Find the first occurrence of a specific character in a given string. Return a pointer to the occurrence in the string, or zero if it is not found.
  3. Take two strings as arguments. If the first exists in the second as a substring, return a pointer to the first occurrence, otherwise zero.

Exercise 5.6. Explain the examples using malloc to somebody else.