hi guys! please help me... :cry: i really don't know how to do this...

part of the specs in my program is to show values after i used some formulas...but i need to make it such that i can scroll down/up to view my results, since i'll need to display a lot of numbers...

can you please give me some tips or something on how to do this?

thanks in advance!

You could pause after a certain number of results have been displayed, or write to a file and let your file reader handle the issue of scrolling. If you really want to do it yourself, and you want to use a console mode program, then you need several things:

1) A way to clear the screen OR a way to position the output cursor
2) A data structure large enough to hold all of your results.
3) A way to signal a message to scroll from the user (most people like the arrow keys)
4) A window of how many lines are to be displayed at once.

If you have all of this, you can write something like the following:

#include <conio.h>
#include <stdio.h>
#include <stdlib.h>

#define length(x) (sizeof (x) / sizeof (*x))

static const char *data[] = {
  "This is a test",
  "Another test",
  "A third test",
  "Keep on going",
  "Not gonna stop soon",
  "Yep, this is fun",
  "Getting bored now",
  "Are we there yet?",
  "Close, but not quite",
  "Only a few more",
  "Fingers are tired",
  "Home stretch",
  "We made it!",

int main(void)
  const int window = 3;
  int start = 0, i;
  int done = 0;

  while (!done) {
    for (i = 0; i < window; i++)
      puts(data[(start + i) % length(data)]);
    switch (getch()) {
    case 'u':
      if (start == 0) start = length(data) - 1;
      else --start;
    case 'd':
      if (start == length(data) - 1) start = 0;
      else ++start;
    case '\r':
      done = 1;

  return 0;
This article has been dead for over six months. Start a new discussion instead.