PDA

View Full Version : Xcode 4.6 broken?




Davy.Shalom
Jul 13, 2013, 02:07 AM
Hey all,
So I'm just getting in to coding and I've written a couple of calculator apps in C through Xcode. This morning they were compiling and running fine. They were fully functional. Now neither of them will work properly. The first printf("contents etc. etc.") will print out properly, and then after that it's like the program just ends. I deleted Xcode and am currently re-downloading it to see if this solves the problem. However, if this happens again in the future I would like to know what I can do to solve it.

Any help is appreciated.

Thanks



gnasher729
Jul 13, 2013, 02:47 AM
Hey all,
So I'm just getting in to coding and I've written a couple of calculator apps in C through Xcode. This morning they were compiling and running fine. They were fully functional. Now neither of them will work properly. The first printf("contents etc. etc.") will print out properly, and then after that it's like the program just ends. I deleted Xcode and am currently re-downloading it to see if this solves the problem. However, if this happens again in the future I would like to know what I can do to solve it.

Any help is appreciated.

Thanks

Rule #1: It's not your tools fault, it is your fault. You changed your code (maybe the cat jumped on the keyboard and changed your code) and now it doesn't work. Fix your code. Deleting and re-downloading Xcode was a waste of time.

Rule #2: Turn on all the compiler warnings you can find. This will show you many bugs in your code.

Rule #1 is meant seriously. If you think something in the universe is working against you, instead of saying: "I made a mistake. What is the mistake? " you'll never get far.

Davy.Shalom
Jul 13, 2013, 03:08 AM
Rule #1: It's not your tools fault, it is your fault. You changed your code (maybe the cat jumped on the keyboard and changed your code) and now it doesn't work. Fix your code. Deleting and re-downloading Xcode was a waste of time.

Rule #2: Turn on all the compiler warnings you can find. This will show you many bugs in your code.

Rule #1 is meant seriously. If you think something in the universe is working against you, instead of saying: "I made a mistake. What is the mistake? " you'll never get far.

Ok well I reinstalled it and you're right. Waste of time. Still not working.

You see I didn't think that Xcode could have suddenly just failed! But to prove to you that there is something wrong, would you mind supplying me with some code that involves a printf/scanf input and a printf output (verified in your version of Xcode)? I'll make a new project and run it, and it will not work.

Well it's late and maybe I'm just not thinking correctly. I'll revisit this tomorrow.

ArtOfWarfare
Jul 13, 2013, 07:53 AM
Ok well I reinstalled it and you're right. Waste of time. Still not working.

You see I didn't think that Xcode could have suddenly just failed! But to prove to you that there is something wrong, would you mind supplying me with some code that involves a printf/scanf input and a printf output (verified in your version of Xcode)? I'll make a new project and run it, and it will not work.

Well it's late and maybe I'm just not thinking correctly. I'll revisit this tomorrow.

No, that's backwards and requires more effort on our part than helping you than it should.

You copy and paste your code here, we tell you either:
A - It works fine when we copy and paste it into our copies of Xcode, meaning that you likely have an odd compiler setting or something - we'll deal with that in the unlikely event it occurs. Or more likely,
B - The issue with your code.

gnasher729
Jul 13, 2013, 10:50 AM
Ok well I reinstalled it and you're right. Waste of time. Still not working.

You see I didn't think that Xcode could have suddenly just failed! But to prove to you that there is something wrong, would you mind supplying me with some code that involves a printf/scanf input and a printf output (verified in your version of Xcode)? I'll make a new project and run it, and it will not work.

Well it's late and maybe I'm just not thinking correctly. I'll revisit this tomorrow.

Go back to Rule #1: You made a mistake. Accept that as a fact. Now the question is: Which mistake did you make?

The easiest way would be to set a breakpoint on the first line in your main () function and step through your code. Or post your code here.

Davy.Shalom
Jul 13, 2013, 12:05 PM
Well here is my first program. Please keep it mind it isn't elegant or complex, but if you can find my error I'd be very grateful. When I run this code, the output box shows "Enter an integer between 1 and 100:"

When I enter anything at all, it will just stop there. Please see the attached image.


#include <stdio.h>

int main(void)
{

//local declarations
int num;
int lineCount;

//statements
printf ("Enter an integer between 1 and 100:" );
scanf("%d", &num);

//test number
if (num > 100)
num = 100;

lineCount = 0;
while (num > 0)
{
if (lineCount < 10)
lineCount++;
else {
printf("\n");
lineCount = 1;

} // end else
printf("%4d", num--);
} // end while
return 0;
} //end main

Image

gnasher729
Jul 13, 2013, 01:32 PM
On a Macintosh, the "Return" key and the "Enter" key are different keys and behave differently. Pressing the "Enter" key or Control-C will stop the program. Use the "Return" key on the main keyboard.

Davy.Shalom
Jul 13, 2013, 03:06 PM
On a Macintosh, the "Return" key and the "Enter" key are different keys and behave differently. Pressing the "Enter" key or Control-C will stop the program. Use the "Return" key on the main keyboard.

I'm an idiot. I've been using Mac OS since OS 9 and I made that error. Many thanks for the sanity check!

ArtOfWarfare
Jul 13, 2013, 03:23 PM
I'm an idiot. I've been using Mac OS since OS 9 and I made that error. Many thanks for the sanity check!

I have as well, but I never knew this.