71.6k views
0 votes
Write an expression that whose value is the fifth character of the string name.

User Dr Nic
by
7.6k points

1 Answer

5 votes
int j;
j="name"[4];
// you could do
j=0; // since name has four letters the fifth character is the terminating 0
now if the string name is name
you could do
j=name[4]; // or even 4[name]

User Lucas Azevedo
by
6.9k points