Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 13, 2013, 02:07 AM   #1
Davy.Shalom
macrumors 6502
 
Join Date: Dec 2008
Xcode 4.6 broken?

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
__________________
-Macbook Pro 13" 2.9 GHz i7, 16 GB RAM, 750 GB HD
-Mac Pro 8 core (3 GHz Xeon), 10 GB RAM, ATI Radeon X1900
-PowerMac G5: 2 x 2.3 GHz, 14 GB RAM, 1.5 TB HD
Davy.Shalom is offline   0 Reply With Quote
Old Jul 13, 2013, 02:47 AM   #2
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by Davy.Shalom View Post
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.

Last edited by gnasher729; Jul 13, 2013 at 02:52 AM.
gnasher729 is offline   0 Reply With Quote
Old Jul 13, 2013, 03:08 AM   #3
Davy.Shalom
Thread Starter
macrumors 6502
 
Join Date: Dec 2008
Quote:
Originally Posted by gnasher729 View Post
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.
__________________
-Macbook Pro 13" 2.9 GHz i7, 16 GB RAM, 750 GB HD
-Mac Pro 8 core (3 GHz Xeon), 10 GB RAM, ATI Radeon X1900
-PowerMac G5: 2 x 2.3 GHz, 14 GB RAM, 1.5 TB HD
Davy.Shalom is offline   0 Reply With Quote
Old Jul 13, 2013, 07:53 AM   #4
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by Davy.Shalom View Post
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.
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.

Last edited by ArtOfWarfare; Jul 13, 2013 at 11:12 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Jul 13, 2013, 10:50 AM   #5
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by Davy.Shalom View Post
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.
gnasher729 is offline   0 Reply With Quote
Old Jul 13, 2013, 12:05 PM   #6
Davy.Shalom
Thread Starter
macrumors 6502
 
Join Date: Dec 2008
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.


Code:
#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
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2013-07-13 at 10.04.26 AM.png
Views:	38
Size:	245.7 KB
ID:	422971  
__________________
-Macbook Pro 13" 2.9 GHz i7, 16 GB RAM, 750 GB HD
-Mac Pro 8 core (3 GHz Xeon), 10 GB RAM, ATI Radeon X1900
-PowerMac G5: 2 x 2.3 GHz, 14 GB RAM, 1.5 TB HD

Last edited by SandboxGeneral; Jul 13, 2013 at 01:29 PM. Reason: Merged consecutive posts
Davy.Shalom is offline   0 Reply With Quote
Old Jul 13, 2013, 01:32 PM   #7
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
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.
gnasher729 is offline   0 Reply With Quote
Old Jul 13, 2013, 03:06 PM   #8
Davy.Shalom
Thread Starter
macrumors 6502
 
Join Date: Dec 2008
Quote:
Originally Posted by gnasher729 View Post
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!
__________________
-Macbook Pro 13" 2.9 GHz i7, 16 GB RAM, 750 GB HD
-Mac Pro 8 core (3 GHz Xeon), 10 GB RAM, ATI Radeon X1900
-PowerMac G5: 2 x 2.3 GHz, 14 GB RAM, 1.5 TB HD
Davy.Shalom is offline   0 Reply With Quote
Old Jul 13, 2013, 03:23 PM   #9
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by Davy.Shalom View Post
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.
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 10:36 AM
Inverter broken or LCD screen broken ? Macbook white A1181 Snappaz MacBook 7 Oct 5, 2012 08:18 AM
Xcode 3 vs Xcode 4 when dealing with Objective-C timebourne Mac Programming 8 Sep 23, 2012 05:36 PM
XCode 4.4.1 to Xcode 4.5 in Mountain Lion VinegarTasters OS X 10.8 Mountain Lion 2 Sep 19, 2012 08:55 PM
Post a picture of your broken/partially broken apple product Revomonster Picture Gallery 6 Aug 6, 2012 01:28 PM

Forum Jump

All times are GMT -5. The time now is 04:51 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC