Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes between Version 3 and Version 4 of StringAndNumberLiteralsExample

Show
Ignore:
Author:
nascent (IP: 67.110.217.136)
Timestamp:
05/30/10 22:10:25 (14 years ago)
Comment:

Updated to be version agnostic.

Legend:

Unmodified
Added
Removed
Modified
  • StringAndNumberLiteralsExample

    v3 v4  
    2626*/ 
    2727 
    28 const char[] myName = x"4A 75 73 74 69 6E";  
    29 const char[] notRaw = "string\tstring"; 
     28const string myName = x"4A 75 73 74 69 6E";  
     29const string notRaw = "string\tstring"; 
    3030 
    3131 
    3737*/ 
    3838 
    39 const char[] raw1 = r"string\tstring"; 
    40 const char[] raw2 = `string\tstring`; 
    41 const char[] raw3 = `apostrophe: '  fancy quote: ` ~ "`"; 
     39const string raw1 = r"string\tstring"; 
     40const string raw2 = `string\tstring`; 
     41const string raw3 = `apostrophe: '  fancy quote: ` ~ "`"; 
    4242 
    4343 
    6262{ 
    6363    /* Print "1000000" */ 
    64     printf("%i\n", million);     
     64    writef("%i\n", million);     
    6565 
    6666    /* Print "2" */ 
    67     printf("%i\n", binTwo);   
     67    writef("%i\n", binTwo);   
    6868 
    6969    /* Print "16" */ 
    70     printf("%i\n", hexSixteen);   
     70    writef("%i\n", hexSixteen);   
    7171 
    7272    /* Print "8" */ 
    73     printf("%i\n", octEight);   
     73    writef("%i\n", octEight);   
    7474 
    7575    /* Print "jcc7" */ 
    76     printf("%.*s\n", myName);    
     76    writef("%s\n", myName);    
    7777 
    7878    /* Print a string with backslashed characters */ 
    79     printf("\"Invisible\" backslashed characters: %.*s\n", notRaw);  
     79    writef("\"Invisible\" backslashed characters: %s\n", notRaw);  
    8080 
    8181    /* Prints a what-you-see-is-what-you-get string */ 
    82     printf("What-you-see-is-what-you-get [1]: %.*s\n", raw1);    
     82    writef("What-you-see-is-what-you-get [1]: %s\n", raw1);    
    8383 
    8484    /* Prints a what-you-see-is-what-you-get string */ 
    85     printf("What-you-see-is-what-you-get [2]: %.*s\n", raw2);    
     85    writef("What-you-see-is-what-you-get [2]: %s\n", raw2);    
    8686 
    8787    /* Prints a what-you-see-is-what-you-get string */ 
    88     printf("What-you-see-is-what-you-get [3]: %.*s\n", raw3);    
     88    writef("What-you-see-is-what-you-get [3]: %s\n", raw3);    
    8989 
    9090    /* Prints one to five */ 
    91     printf("one-to-five: %.*s\n\n", oneToFive); 
     91    writef("one-to-five: %s\n\n", oneToFive); 
    9292 
    93     printf("This is the first line. 
     93    writef("This is the first line. 
    9494This is the second line. 
    9595I'd say that D is pretty darn cool (third line).