Amazon.com Widgets printf() vs NSLog() query
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 31, 2014, 03:37:46 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 6 - Making Decisions
| | | |-+ printf() vs NSLog() query
Pages: [1] Go Down
Print
Author Topic: printf() vs NSLog() query (Read 8614 times)
Phillip Anthony
Newbie
*
Posts: 37


Email




on: April 28, 2010, 08:00:41 AM

Going over my 1st Edition examples that I have previously coded in, I noticed in Example 6.2 that you used the printf() function.  In the 2nd Edition you switched over to NSLog().

My questions are:
1.  Should we NOT be using printf()?

2.  If not, is there a way to insert a carriage return in NSLog()?  Using "\n" does not work in NSLog().

I think this is all going to be academic in that my concern only matters to Console output, while using a GUI will not concern itself with carriage returns and this is our ultimate goal. 

Did I answer my own question?

Thanks,
Phillip Anthony
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: April 28, 2010, 10:18:30 AM

Yes, you answered your own questions.   I decided to introduce NSLog earlier in the second edition to avoid the use of the C-style character string that printf uses as its first argument.

Cheers,

Steve Kochan
Logged
Phillip Anthony
Newbie
*
Posts: 37


Email




Reply #2 on: April 28, 2010, 05:46:55 PM

Thanks, Steve.

For what it's worth, I have learned quite a bit in just comparing the changes you brought about in the 2nd edition against the same examples in the 1st edition.

Regards,
Phillip
Logged
C-ing.Objectively
Newbie
*
Posts: 25






Reply #3 on: May 26, 2010, 11:48:41 AM

Quote
Using "\n" does not work in NSLog().

Code: (Objective-C)
NSLog(@"line one\nline two");

Works just the same, doesn't it?  Huh
Logged
Marcolavida
Newbie
*
Posts: 1


El Priligy en venezuela asi como Cialis informacion son los medicamentos de la salud del hombre. Pero el Priligy foro es el de la eyaculacion precoz y el Cialis tv trata la disfuncion erectil.

401133631 srsly@gmx.us Marcolavida Marcolavida
WWW




Reply #4 on: November 05, 2011, 02:29:16 PM

Hi all,

I just come across something that I think it is worth to share and worth to understand as well, take a look at the code snippet and try to explain why is it showing 0.000 instead of 5.89

code :

float float32 = 5.89;
long long int int64 = 1;

printf "int64 = dn", int64;
printf "float32 = f n", float32;
printf "int64 = d nfloat32 = f n", int64, float32;


results:
int64 = 1
float32 = 5.890000
int64 = 1
float32 = 0.000000

regards,
Logged

Le presento una farmacia online donde se puede comprar Vigora en linea de confianza. Asimismo algunas personas compran Cialis masticable por internet con descuen
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #5 on: November 05, 2011, 05:18:06 PM

It looks like all your parens and %'s were stripped from the post (as well as \ chars).  Can you try again?

Cheers,

Steve
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.