GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Mar-2005, 13:22
stacy12 stacy12 is offline
New Member
 
Join Date: Jan 2005
Posts: 9
stacy12 is on a distinguished road
Question

printing format


i am trying to print this function 4 right justify ,18 columns formats.
Can anyone help me
below is what i did but , it's not working

CPP / C++ / C Code:
void preorder(NODEPTR p)
{
 int columns = 0;
  if(p != NULL)
    {
      printf("%4d",p->value);

      preorder(p->left);
      preorder(p->right);
      columns++;
      if(columns%18==0)
      printf("\n");


    }
  else
    return;
}
Last edited by LuciWiz : 29-Mar-2005 at 13:31. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 30-Mar-2005, 02:14
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Every time you enter the function, columns is reset to zero. Put static in front of the declaration.

By the way, please tell us what the code is doing so we know what we're looking for. It saves us having to ask for harder problems and you have to post again to explain.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New DVD format in the works: Uses paper Disks! TerryPearson Computer Hardware Forum 3 14-Dec-2004 12:20
Reading and writing binary files in certain format Dream86 C++ Forum 10 06-Aug-2004 11:38
Having trouble trying to format C: Nickster64 Computer Software Forum - Windows 2 27-Jul-2004 08:31
time format gmn MS Visual C++ / MFC Forum 1 13-Jul-2004 19:55
Rookie problem with date format cave monkey MySQL / PHP Forum 4 18-Mar-2004 09:41

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:30.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.