#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
/** below is a basic type literal example */
int a = 10; 10 is an integer literal
float F = 0.5f; 0.5f is a single-precision floating-point number literal
Double d = 3.14; 3.14 is a double-precision floating-point number literal
Long L = 100000L; 100000L is a long integer literal
char c = ' C '; ' C ' is a character type literal
const char *s = "Hello"; "Hello" for a C string literal
/** below is a composite type literal example */
struct Foo {int A, b;};
(struct foo) {. A = ten,. B = 20} is a composite type literal of struct foo
struct Foo foovar = (struct foo) {. A = ten,. b = 20};
(int[]) {1, 2, 3, 4} is a composite type literal of an int[4] array
int *arr = (int[]) {1, 2, 3, 4};
@ "Hello, world" for nsstring literal of string object reference type
NSString *str = @ "Hello, world";
@10, @ (10 + 0.5) are literal literals of the NSNumber object reference type
NSNumber *intnum = @10;
NSNumber *doublenum = @ (10 + 0.5);
@[@0, @1, @2] is the literal of a Nsarray object type; @0, @1, @2 are literals of the NSNumber object type
Nsarray *array = @[@0, @1, @2];
}
Objective-c literal