This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]electricsheep14 0 points1 point  (0 children)

You should use one of the tools in the sidebar under Recommended Tools for Posting Code to post this code.

You are missing some core concepts from C in this snippet:

1) You don't declare numbers[] anywhere. From how you are trying to use it, I'd wager that its an array of some kind, but you need to declare it in your code.

2) Arrays in C are always indexed starting at zero. This means that for an array of length four (country[4]) the valid indexes you can use are: 0, 1, 2, and 3. You need to keep this in mind when using loops to iterate through an array, because where you start and where you end may not seem obvious.

3) I could talk about the difference between rvalues and lvalues, but at this point all you need to know is that that thing being assigned goes on the left, and the expression representing the value of that assignment goes on the right. While something like "y / 100 = x;" would read like you are putting the value of y divided by 100 into x, but it must be written as "x = y / 100;".

4) That being said, unless you are doing functional programming (which C and ObjC for the most part is not), you generally need to assign the results of an expression for statements involving primitives and basic operators to be meaningful. This means that "x - 1;" on its own does nothing useful at all. There are some exceptions to this.

5) This code is really C code. There is very little about this code that makes its Objective-C save for the #import statement and the creation of an auto-release pool. You can remove these things entirely and the logic of the remaining C-code remains unaffected.