简体   繁体   中英

Newline in Objective C using Xcode 4.4

Has anyone had an issue besides me where /n didn't produce a new line in an output string? This is a starter program taken from "Programming in Objective C" Fourth Edition by Stephen Kochan. The code runs without error but prints /n instead of advancing a line which is contrary to the text. Is there an Xcode dialog setting I need to look at or something?

Thanks,

Michael

//  First programming example

#import <'Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // insert code here...
        NSLog(@"Testing..../n....1/n....2/n....3");
    }
    return 0;
}

Objective-C(以及许多其他编程语言...)中的换行符不是\\n /n

Escaping characters is when you use a backslash, not a forward slash, a new line is: \\n and a carriage return is \\r

/n is just... well "/n"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM