Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Can't seem to ring that pole! (http://www.velocityreviews.com/forums/t742212-cant-seem-to-ring-that-pole.html)

Lloyd Fuller 01-18-2011 06:39 AM

Can't seem to ring that pole!
 
I've been working on this for a while, but I just can't seem to ring
that pole!

so here is my function:

const char * earth(int a)
{
const char *myearth;

if (a == 0) {
myearth = "15321.532";
else {
myearth = "a cool 600";
}

return myearth;
}



AND HERE is my main:

int main (void) {
printf("yofoo your earth is %s\n", earth(2));
}

But I get a lot of errors this is a mess. Any kind soul out there
with some advice to help me ring this pole?

Geoff 01-18-2011 07:07 AM

Re: Can't seem to ring that pole!
 
The case of the missing brace. Hurry Watson! The game's afoot!

On Mon, 17 Jan 2011 22:39:07 -0800 (PST), Lloyd Fuller
<unlearnundodisclaimdisdain@hotmail.com> wrote:

>I've been working on this for a while, but I just can't seem to ring
>that pole!
>
>so here is my function:
>
>const char * earth(int a)
>{
> const char *myearth;
>
> if (a == 0) {
> myearth = "15321.532";

} /* <-- here it is */
> else {
> myearth = "a cool 600";
> }
>
> return myearth;
>}
>
>
>
>AND HERE is my main:
>
>int main (void) {
> printf("yofoo your earth is %s\n", earth(2));

return 0;
>}
>
>But I get a lot of errors this is a mess. Any kind soul out there
>with some advice to help me ring this pole?


Ian Collins 01-18-2011 07:37 AM

Re: Can't seem to ring that pole!
 
On 01/18/11 07:39 PM, Lloyd Fuller wrote:
> I've been working on this for a while, but I just can't seem to ring
> that pole!
>
> so here is my function:
>
> const char * earth(int a)
> {
> const char *myearth;
>
> if (a == 0) {
> myearth = "15321.532";
> else {
> myearth = "a cool 600";
> }
>
> return myearth;
> }
>
>
>
> AND HERE is my main:
>
> int main (void) {
> printf("yofoo your earth is %s\n", earth(2));
> }
>
> But I get a lot of errors this is a mess. Any kind soul out there
> with some advice to help me ring this pole?


Does your editor auto-indent? If so, it will show you the missing
closing brace!

--
Ian Collins

litchie 01-18-2011 03:21 PM

Re: Can't seem to ring that pole!
 
You should delete the left bracket after `if (a == 0)'.

mikey@mouse.local 01-20-2011 07:43 AM

Re: Can't seem to ring that pole!
 
On Mon, 17 Jan 2011 22:39:07 -0800 (PST), Lloyd Fuller
<unlearnundodisclaimdisdain@hotmail.com> wrote:

>I've been working on this for a while, but I just can't seem to ring
>that pole!
>
>so here is my function:
>
>const char * earth(int a)
>{
> const char *myearth;
>
> if (a == 0) {
> myearth = "15321.532";
> else {
> myearth = "a cool 600";
> }
>
> return myearth;
>}
>
>
>
>AND HERE is my main:
>
>int main (void) {
> printf("yofoo your earth is %s\n", earth(2));
>}
>
>But I get a lot of errors this is a mess. Any kind soul out there
>with some advice to help me ring this pole?


const char * earth(int a)
{
const char *myearth;

if (a == 0)
myearth = "15321.532";
else
myearth = "a cool 600";

return myearth;
}



int main (void)
{
printf("yofoo your earth is %s\n", earth(2));
return 0;
}


All times are GMT. The time now is 02:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57