printing char **array;

This is a discussion on printing char **array; within the C++ Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> int main(void) { char **array; while ( **array != '

Thread: printing char **array;

' ){ printf("%s",*array); printf("\n"); **array++; if (**array == ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    93

    printing char **array;

    Code:
    #include <stdio.h>
    
    int main(void)
    {
    
    char **array;
    
     while ( **array != '\0' ){
        printf("%s",*array);
        printf("\n");
        **array++;
        if (**array == '\0')
        break;
     }
    
    return 0;
    
    }


    This is printing the words in the array but it won't end. It creates an infinite loop. I always thought a string ended in a null character. Its like it can't find the null character. Anybody know why this would create an infinite loop?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Well, this isn't real code.... please try to come up with a small, but real example that actually demonstrates the problem.

    One issue I will say right away is that you're using a char **. There is no requirement that a char ** have a terminating '\0' since it is not a string in and of itself. Also.... **array++; is probably not really what you want.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    93
    I think I figured it out. Thanks anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 05:59 AM
  2. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  3. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  4. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 08:21 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

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