Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does L do?

Tags:

c++

c

string

What does this do?

const wchar_t *s = L"test";

If wchar_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, four bytes in size?

like image 442
shebaw Avatar asked Apr 15 '11 16:04

shebaw


People also ask

What is S and L on gear shift?

S is Sport mode. It will make the throttle sharper and keep the rpms higher. Imagine a normal auto holding gears longer before shifts. L is for low gear. It would be used when going down a steep grade.

What is the L for in an automatic car?

L – Low Gear: This position is typically used for towing or driving on steep inclines. S - Sport: Puts the car into a lower gear so you can have more power and control when accelerating. M - Manual: This position allows you to shift gears manually, giving you more control over your car's speed.

Can I shift from L to D while driving?

Yes, you can shift from D to L while moving in an automatic transmission car. Today's transmission are electronic. There are rev limiters for shifting to lower gears. The transmission simply won't shift to a lower gear above a certain RPM for each gear.


1 Answers

The L means that string is a string of wchar_t characters, rather than the normal string of char characters. I'm not sure where you got the bit about four bytes from.

From the spec section 6.4.5 String literals, paragraph 2:

A character string literal is a sequence of zero or more multibyte characters enclosed in double-quotes, as in "xyz". A wide string literal is the same, except prefixed by the letter L.

And an excerpt from paragraph 5:

For character string literals, the array elements have type char, and are initialized with the individual bytes of the multibyte character sequence; for wide string literals, the array elements have type wchar_t, and are initialized with the sequence of wide characters corresponding to the multibyte character sequence, as defined by the mbstowcs function with an implementation-defined current locale.

like image 84
Carl Norum Avatar answered Oct 06 '22 01:10

Carl Norum