Posted: 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
Nick
Posted: 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
Posted: 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
Posted: 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
Posted: 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
Posted: 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
Posted: 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.