- Joined
- Jan 14, 2009
- Messages
- 6
- Reaction score
- 0
- Points
- 1
I wrote a C program that worked perfectly in Windows, but I am having trouble using Mac OS. In Windows I used DevC++ to compile and run the program.
When I tried to compile it in Xcode, it gave me an incorrect output. It kept giving me "inf" and "nan" for what I'm assuming is "infinite" and "not a number." It seems like it's not correctly calculating "eta" on line 121 of my source code (attached).
I thought it might be a compiler problem so I tried to compile it from the command line using gcc. I used the command:
gcc SLP.c -o SLP
It would not compile. This is the error I would get:
SLP.c:1:19: error: stdio.h: No such file or directory
SLP.c: In function ‘main’:
SLP.c:41: warning: incompatible implicit declaration of built-in function ‘printf’
It seems like there is a problem with my OS recognizing the stdio.h library. I've never had a problem with any C program with Xcode before. I did recently reinstall Xcode with the iPhone SDK. I want to reiterate that my program ran fine with DevC++ on Windows.
I've attached my code in case anyone wants to look at it. I had to attach it as a text file because a .c file would not upload. Just change the file extension. The correct final outputs should be w(0) = -4, w(1) = 2 and w(2) = 3.
View attachment SLP.txt
When I tried to compile it in Xcode, it gave me an incorrect output. It kept giving me "inf" and "nan" for what I'm assuming is "infinite" and "not a number." It seems like it's not correctly calculating "eta" on line 121 of my source code (attached).
I thought it might be a compiler problem so I tried to compile it from the command line using gcc. I used the command:
gcc SLP.c -o SLP
It would not compile. This is the error I would get:
SLP.c:1:19: error: stdio.h: No such file or directory
SLP.c: In function ‘main’:
SLP.c:41: warning: incompatible implicit declaration of built-in function ‘printf’
It seems like there is a problem with my OS recognizing the stdio.h library. I've never had a problem with any C program with Xcode before. I did recently reinstall Xcode with the iPhone SDK. I want to reiterate that my program ran fine with DevC++ on Windows.
I've attached my code in case anyone wants to look at it. I had to attach it as a text file because a .c file would not upload. Just change the file extension. The correct final outputs should be w(0) = -4, w(1) = 2 and w(2) = 3.
View attachment SLP.txt