Why don't I get an answer? Am I doing something wrong?


#1

I posted, on the following page:
viewtopic.php?f=170&t=3495
the following and received no replies (Am I doing something wrong?):
Re: 1st Edition Errata
by johnhook » Sun Apr 01, 2012 9:39 pm

Please Help!
The Second Edition, page 11 shows:
int main (int argc, const char * argv[]) {
While Xcode returns:
int main(int argc, const char * argv[])
{

  1. Which is correct and why?
  2. Does this cause or contribute to the errata comments about pages 28 and 32 by geo3rge and if so how, whatever and why etc.?

Thanks…
johnhook

Posts: 3
Joined: Sun Apr 01, 2012 9:23 pm
Top
Re: 1st Edition Errata
by johnhook » Sun Apr 01, 2012 10:55 pm

Now that I typed the exact syntax:
#include <stdio.h>

int main (int argc, const char * argv[]) {

// insert code here…
printf(“Hello, World!\n”);
return 0;

}
the program now runs and returns:
Hello, World!
but the question still remains, why does Xcode return the following incorrect syntax which does not compile and run?
int main(int argc, const char * argv[])
{
instead of:
int main (int argc, const char * argv[]) {
which does compile and run! ???

Thanks…
johnhook

Posts: 3
Joined: Sun Apr 01, 2012 9:23 pm
Top
Re: 1st Edition Errata
by johnhook » Sun Apr 01, 2012 11:05 pm

This build compiled and ran:
#include <stdio.h>

int main (int argc, const char * argv[])
{
// Print the beginning of the novel
printf(“It was the best of times.\n”);
printf(“It was the worst of times.\n”);
/* Is that acrially any good?
Maybe it needs a rewrite. */

return 0;
}
and returned the correct Output:
It was the best of times.
It was the worst of times.
but again, why is Xcode returning the slightly incorrect syntax that has to be corrected before I can compile and run and get the correct return?

Thanks…


#2

Rather than replying and adding your comment to someone else’s post why don’t you create a new topic of discussion.


#3

The presence of an open-curly ({) at the end of a line of code or at the beginning of the following line is not relevant. There must be another difference that is accounting for the compilation errors that you’re experiencing.

More specifically, the amount of whitespace between bits of code doesn’t matter. If there is any whitespace at all, there can be any amount of it.

is no more or less valid than

int main(int argc, const char * argv[]) {.

What compilation errors are you receiving from Xcode?