Thread: Basic debugging question

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    1

    Basic debugging question

    I was given the following program and asked to debug it but I am having an issue understanding some of the code in it. First of all I can't seem to find out what the const char ** means. Secondly, in the final printf statement it appears that the %s string is not printing when the program is runned. Can anyone point in the right direction with this one?

    Code:
         #include <stdio.h>
         #define DOCTORATE 1
         #define CHOICE 2
         const char *a[2][3] =
             {
             {"Hitler", "Stalin", "Bin Laden"},
             {"Clinton", "Bush", "Powell" }
             };
         int main()
             {
             const char **array;
         #if D0CT0RATE
             array = a[1];
         #else
             array = a[0];
         #endif
             printf( "An honorary doctorate award "
               " is issued to %s\n",
               array[CHOICE] );
             }

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    21
    const char** is for constant pointer to a pointer which is of type char data, means that you cannot change values of array a, and btw %s is printing fine...

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    "When the program is runned."

    Seriously?

    We're really making authors and wordsmiths of the English language, roll over in their graves, tonight!

  4. #4
    Registered User Alan.Brown's Avatar
    Join Date
    Jul 2010
    Location
    NSW, Australia
    Posts
    9

    Red face

    Line 2 - DOCTORATE - Letter 'O'
    Line 12 - D0CT0RATE - Zeroes instead of the letter 'O'

    Try to compile the program. Any error messages will give an indication as the what the problem is. If you don't understand the messages, post them here and we can help you.

    @Adak - sometimes English is not the primary language of the poster and mistakes therefore will be made. The OP's problem is one of coding C language not writing English language.

    BTW In your last sentence commas are unnecessary!! Methinks the biter is bit!!
    Last edited by Alan.Brown; 05-01-2012 at 08:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple question about GDB debugging
    By meili100 in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 02:05 PM
  2. Debugging question
    By Dark_Phoenix in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2007, 02:02 PM
  3. Debugging question
    By SaltyMilk in forum C Programming
    Replies: 3
    Last Post: 05-30-2005, 02:33 PM
  4. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  5. Debugging Question
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 12-19-2001, 05:42 PM

Tags for this Thread