Amazon.com Widgets Exercice 1 A$
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 19, 2013, 08:36:20 PM
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
| |-+  Answers to Exercises
| | |-+  Chapter 3
| | | |-+  Exercice 1 A$
Pages: [1]   Go Down
Print
Author Topic: Exercice 1 A$  (Read 2010 times)
Etdashou
Newbie
*
Posts: 2






« on: August 03, 2009, 09:20:12 AM »

Hi,

at page 34 you say that $-is not a valid character. So I thought that A$ would not be ok.
However I did this code:
Code: (Objective-C)
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int Int;
int playNextSong;
//int 6_05; PAS BON
int _calloc;
int Xx;
int alphaBetaRoutine;
int clearScreen;
int _1312;
int z;
int ReInitialize;
int _;
int A$;

z = 9;
A$ = 7;

    // insert code here...
    NSLog(@"Hello, World!%i", A$);
    [pool drain];
    return 0;
}

And everything is running ok and I have the output:
Quote
[Session started at 2009-08-03 12:17:12 -0400.]
2009-08-03 12:17:12.665 ex_1[3994:10b] Hello, World!7

The Debugger has exited with status 0.

Any help is appreciated!
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #1 on: August 03, 2009, 10:08:42 AM »

You're right.  The $ is accepted for use in identifiers in GNU C/Objective-C (gcc) implementations, but is not part of the ANSI-C standard.   So it is legal for gcc, but not necessarily portable to other systems.  This may not be an issue to you as a developer of Objective-C programs that will only run under MAC OS X or on the iPhone.

Cheers,

Steve Kochan
Logged
Etdashou
Newbie
*
Posts: 2






« Reply #2 on: August 03, 2009, 11:19:58 AM »

Perfect than you!
Logged
Halftrip
Newbie
*
Posts: 1






« Reply #3 on: November 21, 2010, 12:54:55 AM »

Hi,

I'm new to Objective-C although I've programmed extensively in other languages and on other platforms.  I, too, tried the same test as our friend here.  I wasn’t too surprised to see that A$ worked as a variable as when I used to program in BASIC back in the 70’s, a dollar sign after a letter denoted a string variable.  I am curious if this is just a coincidence.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #4 on: November 22, 2010, 07:37:50 AM »

Yes, I see no correlation between the acceptance of the $ and its use in BASIC for string variables (that does bring back memories!).

Cheers,

Steve
Logged
scarubia
Newbie
*
Posts: 38


Email




« Reply #5 on: September 11, 2011, 12:01:01 PM »

Should Int be invalid?
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.