Concatenate strings and append strings
/* Concatenate two strings NSString * str1 = @ 123; NSString * str2 = @ abc;? A complete character string. */# Import
Int main (int argc, const char * argv []) {/* method 1 * // NSString * str1 = @ 123; // NSString * str2 = @ abc; /// NSString * str3 = [[NSString alloc] initWithFormat: @ % @, str1, str2]; // NSLog (@ % @, str3 ); /* method 2 */NSString * str1 = @ 123; NSString * str2 = [str1 stringByAppendingString: @ abc]; NSLog (@ % @, str2 );}
/* After the string @ price? Surface appending? A slave terminal? Any floating point number ,? Generate a new string. Do you want to retain two? Decimal. */# Import
Int main (int argc, const char * argv []) {NSString * str1 = @ price:; float floatNumber; scanf (% f, & floatNumber ); NSString * str2 = [[NSString alloc] initWithFormat: @ %. 2f, floatNumber]; NSString * str3 = [[NSString alloc] initWithFormat: % @, str1, str2]; NSLog (@ % @, str3); return 0 ;}