Saltar al contenido

Lesson 75: String handling

English

Exam strings and C++ strings

Exam C++
LENGTH(T) t.length()
UCASE(T) t.toUpperCase()
LCASE(T) t.toLowerCase()
SUBSTRING
(T, 7, 16)
t.substring(6, 22)
  • toUpperCase() changes the string itself; it does not return a new one.

  • The exam counts positions from 1 and gives a length. C++ counts from 0 and gives the index just after the end.

  • So exam position 7 is C++ index 6, and 16 characters later the end is index 22.

Iniciar sesión o crear cuenta

IGCSE, A-Level & AP