Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Pointers and Memory Structs

Sebastian Nitu
Sebastian Nitu
8,616 Points

Why does Xcode ask me for ";"?

Hello, I am pretty much certain that I am the one coins something wrong here but I cannot explain myself why is Xcode prompting me with the error in this screenshot.

I am starting to think that programming might not be for me...

7 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Just as John W mentioned:

#include <stdio.h>

typedef struct {
    float center[3];
    float radius;
} Sphere;

Sphere makeSphere (float *c, float r);


int main()
{


}

Sphere makeSphere (float *c, float r)
{

        Sphere sphere;
        sphere.center[0] = *c[0];
        sphere.center[1] = *c[1];
        sphere.center[2] = *c[2];

        sphere.radius = r;
        return Sphere;
}

yes you are just missing ; at the end of the statement !

You are trying to define a function inside a function. Just move the whole thing outside of main() and it should fix it.

Just put a " ; " at the end, does it go away?

Sebastian Nitu
Sebastian Nitu
8,616 Points

I believe the construct itself shouldnt have a ";" and if a do put a ";" it invalidarea everything beneath. In the example from the video, there is no ";" before opening the querly braces

try this

#include <stdio.h>

typedef struct {
    float center[3];
    float radius;
} Sphere;

Sphere makeSphere (float *c, float r);


int main()
{
}

Sphere makeSphere (float *c, float r)
{

        Sphere sphere;
        sphere.center[0] = *c[0];
        sphere.center[1] = *c[1];
        sphere.center[2] = *c[2];

        sphere.radius = r;
}