Newbie issues programming C w/i Xcode

This is a discussion on Newbie issues programming C w/i Xcode within the C Programming forums, part of the General Programming Boards category; Hello, I'm completely new to programming. I heard great things about the book, "C by Example," and fortunately, my library ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    2

    Newbie issues programming C w/i Xcode

    Hello,

    I'm completely new to programming. I heard great things about the book, "C by Example," and fortunately, my library has an ebook version of it. For the very first program the book instructs us to run, I copied and pasted the code directly from the ebook into Xcode, but it won't run! I'm totally new, so just trying to get a hang of things. Any ideas of what's going on?

    Thanks!

    Screen shot 2010-06-08 at 7.32.38 PM.png

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    999
    The double single quotes (') at the beginning of the printf statement should be a single double quote (")

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Why don't you just post the code ?

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    '' (two single quotes) is not the same thing as " (double quote).

    main returns an int.
    Code:
    int main(void)

  5. #5
    Registered User
    Join Date
    Jun 2010
    Posts
    2
    Thanks guys, the quote was the issue. I haven't gotten to the chapter where we learn to analyze the structure of C code, so I was totally oblivious to that being the issue. I just couldn't figure out why a direct copy and paste of the code wouldn't run!

    I'm glad to have found a forum with such a great community as I take on the huge endeavor of learning C (and later Objective-C)!

    BTW, for those interested, the code is below:

    /* Filename: C1FIRST.C
    Requests a name, prints the name 5 times, and rings a bell */


    #include <stdio.h>
    #define BELL '\a'


    main()
    {
    int ctr=0; /* Integer variable to count through loop */
    char fname[20]; /* Define character array to hold name */


    printf("What is your first name? "); /* Prompt the user */
    scanf(" %s", fname); /* Get the name from the keyboard */
    while (ctr < 5) /* Loop to print the name */
    { /* exactly 5 times */
    printf("%s\n", fname);
    ctr++;
    }
    printf("%c", BELL); /* Ring the terminal's bell */
    return 0;
    }

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,847
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 03-09-2011, 06:38 AM
  2. Need help from you Xcode users
    By Memloop in forum Tech Board
    Replies: 7
    Last Post: 09-22-2009, 11:27 AM
  3. Replies: 16
    Last Post: 04-20-2008, 02:15 PM
  4. open gl newbie issues
    By phil_drew in forum Windows Programming
    Replies: 3
    Last Post: 10-30-2003, 03:26 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 03:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21