Thread: Weird printw.

  1. #1
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69

    Weird printw.

    After reading a tutorial about ncurses i was trying to make a pong like game, after a big struggle with finding something remotley alike kbhit() i found a "home made" version after implementing it i found something wierd.

    Code:
    for( ;; )
    {
       loop_count++;
     
       if (kbhit())
         {
              key = getch();
    
              switch(key)
                 {             
                     case up:
                         do stuff
                           ...
                  }
          }
    printw("%d", loop_count);
    }
    this code show the variable loop_count After you press any keys but if you replace it with printf("%d", loop_count);
    it work like a charm... why is this and is there a way around it? since printf doesnt seem to work very well with ncurses i would very much like to replace it.
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

  2. #2
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69
    Oops missed a refresh()
    no replies though .. kinda sad
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>no replies though .. kinda sad
    Give us a chance pal (ie more than a few hours)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69
    Give us a chance pal (ie more than a few hours)
    I gave you a day
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

  5. #5
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Is your prntf() the last statement in your code? if yes, insert a redundant getch() just before endwin().

  6. #6
    Registered User Fredd's Avatar
    Join Date
    Oct 2002
    Posts
    69
    Is your prntf() the last statement in your code? if yes, insert a redundant getch() just before endwin().
    Thanks... but the refresh() kinda made it work
    "Writing software is more fun than working."

    got slack?
    http://www.slackware.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM