| OS X - Development and Darwin Discussion and questions about development for Mac OS X. |
| Thread Closed |
|
|
Thread Tools |
![]() Member Since: Aug 03, 2009
Posts: 2
![]() |
Alright im new to both C and xcode right now, im looking for a bit of help.
Im trying to learn C right now using "the C programming language" book. I am trying to work though the examples, and im still trying to work out the kinks before I really get into it. when I open a new project and use the standard tool it offers this code for the hello world program Code:
#include <stdio.h>
int main ()
{
printf("Hello, World!");
return 0;
}
Code:
#include <stdio.h>
main ()
{
printf("Hello, World!");
}
Also iv noticed both these programs will print if i open them in "console", and it will also run with the same result if I remove the \n, which I definitely cant explain. |
![]() Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
|
Is the warning "warning: return type defaults to 'int'"?
When code or scripts are run from the command line, they are expected to return an 'int' value relating to success or some failure. The compiler seems to be insisting on it. I would consider that a good thing. By the way, I tried using 'void' instead and the compiler warned me I wasn't using an 'int' value. Perhaps the version of the book isn't up to date on this, has excluded the information for brevity, or the newer compiler is just being helpful. The latest version of that book is 11 years old. A lot has happened in compiler design since then. As for the '\n'. That is simply a line feed. Removing it will will do no harm here. On the command line the cursor will be at the end of the period if you remove that token. The would mean another print line would start printing at that location. CameraTime - Time lapse photography for novice and advanced users. When asking questions, post the version of your software. You'll receive better answers. Please post your results to the thread as it is good feedback.
|
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,336
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Quote:
Note that before I show an example, my examples are in Python so ignore the fact that my code looks different. I'm just trying to illustrate what the "\n" does. So, let's say I execute the following command: Code:
print("Hello World!")
Code:
print("Hello\nWorld!")
Hello World! Hope that helps. Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
|||||
![]() Member Since: Feb 02, 2004
Location: PA
Posts: 12,455
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook
|
__________________________________________________ Posting and YOU|Forum Community Guidelines|The Apple Product Cycle|Forum Courtesy mac: a waterproof raincoat made of rubberized fabric MAC: a data communication protocol sub-layer, also known as the Media Access Control Mac: a brand name which covers several lines of personal computers designed, developed, and marketed by Apple Inc.
|
| Thread Closed |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Carbon framework on XCode | Rafi Shalom | OS X - Development and Darwin | 1 | 04-17-2008 01:14 PM |
| keyboard stops working, only in Finder? Help! | coolskierguy | OS X - Operating System | 0 | 02-25-2008 12:56 PM |
| Xcode 1.5 | alejandrico | OS X - Development and Darwin | 0 | 06-03-2006 05:56 PM |
| Features I miss from Visual Studio, now using xCode... | RChickenMan | OS X - Development and Darwin | 0 | 10-18-2005 11:14 AM |
| XCode Include path problem | Jove | OS X - Development and Darwin | 0 | 03-18-2005 09:41 AM |
All times are GMT -4. The time now is 04:10 PM.
Powered by vBulletin