473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Output is Getting scattered after using curses function

Expand|Select|Wrap|Line Numbers
  1.  #include<iostream>
  2.   2 #include <ncurses.h>
  3.   3 #include <curses.h>
  4.   4
  5.   5
  6.   6 using namespace std;
  7.   7
  8.   8 int main()
  9.   9
  10.  10 {
  11.  11
  12.  12 /*
  13.  13 initscr(); // Initalise the ncurses library
  14.  14 cbreak(); // option to disable buffering etc.
  15.  15 noecho(); // disable the echoing of keystrokes
  16.  16 */
  17.  17         int i=0,j=0;
  18.  18
  19.  19         for(i=2;i<=15;i+=3)
  20.  20         {
  21.  21                 initscr();
  22.  22                 cbreak();
  23.  23                 noecho();
  24.  24                 printw("\n-------------------------------------------------\n");
  25.  25                 refresh();
  26.  26                 for(j=1;j<=10;j++)
  27.  27
  28.  28                  printw("%d\t%d\t%d\n",i*j,(i+1)*j,(i+2)*j);
  29.  29                  refresh();
  30.  30
  31.  31                  printw("\n Press Any Key To Continue ! ");
  32.  32                  refresh();
  33.  33
  34.  34                  getch();
  35.  35 //               system("clear");
  36.  36         }
  37.  37 refresh(); // update the screen, so the text is      displayed
  38.  38
  39.  39
  40.  40 printw("\n Press Any Key To Exit ");
  41.  41 //refresh();
  42.  42
  43.  43 getch();
  44.  
  45.  
  46.  
It prints table upto 10 really wel but after 10 all tables get scatterd . Can anyone please suggets me what is wrong in my code ?
Jan 13 '13 #1
1 1605
donbock
2,426 Expert 2GB
Did commenting out line 35 make the problem go away? Curses is optimized to work with slow displays. A big part of that optimization is to not tell the display to show something that is already there. Invoking the clear system command involves changing what is on the display without telling curses -- turning curses' optimization policy against it.

If you want to clear the screen then do it via curses function clear().
Jan 15 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: vishal | last post by:
i am getting following error. Warning: mail() : Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in...
7
by: Jim Geissman | last post by:
Take a table, where not all the columns are populated: CREATE TABLE #T (A int, B int, C int, D int) INSERT #T (A,B) VALUES (1,2) INSERT #T (A,B) VALUES (3,4) INSERT #T (A,B) VALUES (5,6)...
6
by: Steve Strik | last post by:
Hi, I'm using access 97 SR2 on win XP and keep getting the Sub or Function not defined error message. The code for the function is in a module called mod_Public and is as follows. Function...
8
by: Nick Li | last post by:
Hi, I am trying to writing a c program to send email using system() function call on Unix(Sun Solaris). I tried the following: #include <stdio.h> #include <stdio.h> int main(void) {
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
2
by: vermarajeev | last post by:
Hi, I have a simple question to ask. I was just trying some sample program using friend function. The program goes like this #include<iostream> using namespace std; class B;
12
by: Angel Tsankov | last post by:
I'm thinking about using a function tamplate to verify that an identifier is of an array type. May the following template be used for this purpose: template< typename T, int N > void...
13
by: arnuld | last post by:
this does not work, i know there is some problem in the "for loop" of "print_arr" function. i am not able to correct the weired results i am getting. i have no compile time error, it is only...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
2
myusernotyours
by: myusernotyours | last post by:
Hello everyone. I am using a C library from C++ code. The C library declares some function pointers using typedef, and then makes some variables using this function pointer as the type. Like: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.