Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Is this code suppose to work, or is it for learning?
Index -> Programming, C -> C Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Thu Jan 08, 2009 5:37 pm   Post subject: RE:Is this code suppose to work, or is it for learning?

What's line 15?
Sponsor
Sponsor
Sponsor
sponsor
Nick




PostPosted: Thu Jan 08, 2009 5:45 pm   Post subject: RE:Is this code suppose to work, or is it for learning?

it seems to me that, for some reason, your comments aren't, well, commenting

try to remove the comments then compile
php111




PostPosted: Thu Jan 08, 2009 5:46 pm   Post subject: Re: RE:Is this code suppose to work, or is it for learning?

wtd @ Thu Jan 08, 2009 5:37 pm wrote:
What's line 15?


I don't know. Hold on, I'll post the code from the book that Dan recommended (C Primer Plus).



code:
int main()          // C99 rules

{

// some statements

    int doors;

    doors = 5;      // first use of doors

// more statements

    int dogs;

    dogs = 3;       // first use of dogs

    // other statements

}

Vertico




PostPosted: Thu Jan 08, 2009 5:55 pm   Post subject: Re: Is this code suppose to work, or is it for learning?

php111 @ Thu Jan 08, 2009 6:29 pm wrote:

code:
int main(void) // C99 rules

{

// some statements

int doors;

doors = 5; // first use of doors

// more statements

int dogs;

dogs = 3; first use of dogs

// other statements

}



c:
dogs = 3; first use of dogs

Right here you have a comment without it being set as one. You need // or /* */ around it else the compiler sees "first use of dogs" as a line of code, which of course does not work.
c:
dogs = 3//first use of dogs
OneOffDriveByPoster




PostPosted: Thu Jan 08, 2009 7:30 pm   Post subject: Re: Is this code suppose to work, or is it for learning?

The comments are inaccurate (even if they came from the book)--comments changed below.
c:
// function definition
int main(void) // function prototype for main() suitable for hosted environment:  no implicit int allowed in C99
{
// a declaratation
int doors;

// a statement
doors = 5; // first use of doors

// another declaration
int dogs;

// another statement
dogs = 3; // first use of dogs
}

wtd




PostPosted: Thu Jan 08, 2009 7:39 pm   Post subject: RE:Is this code suppose to work, or is it for learning?

Thanks for just giving php11 the answer.
php111




PostPosted: Thu Jan 08, 2009 7:43 pm   Post subject: Re: Is this code suppose to work, or is it for learning?

I got it. It worked. Thank you. The // is what I needed.
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: