Thread: Can't understand this block of code

  1. #1
    Registered User
    Join Date
    Feb 2010

    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.

    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
    Make Fortran great again Epy's Avatar
    Join Date
    Sep 2009
    California, USA
    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, 02:17 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  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, 02:18 AM