Can't understand this block of code

This is a discussion on Can't understand this block of code within the C Programming forums, part of the General Programming Boards category; Can someone help me to understand why there are semicolons after the brackets in this method, and or what it ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    20

    Can't understand this block of code

    Can someone help me to understand why there are semicolons after the brackets in this method, and or what it actually does? It's part of a program that constructs a sort of linked list.

    Code:
    int print2d (struct node2d *p2d) {
        struct node1d *p1d;
        while (p2d) {
    	printf("The 2d-node has name: %s\n", p2d->name);
    	p1d = p2d->first;
    	while (p1d) {
    	    printf("\t %s has a 1d-node with name %s\n", p2d->name, p1d->name);
    	};
    	p2d = p2d->down;
        };
        return 0;
    }

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    943
    The semicolons after the brackets don't really do anything, they're not needed but don't hurt anything.

    Looks like node2d is a sort of table (linked list) containing several rows (node1d's) and print2d just prints out their names...also looks like the while (p1d) loop is missing the iterating statement, there should be something like "p1d = p1d->next;"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. backward debugging in Visual Studio??
    By George2 in forum Tech Board
    Replies: 12
    Last Post: 11-05-2006, 01:17 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 11:38 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. pointers
    By fanaonc in forum C Programming
    Replies: 3
    Last Post: 11-17-2001, 01:18 AM

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