Hi. I'm new in programing and i have this program that i'm working on right now.
it's still a working progress. but when i run it and choose from the options. the program kept moving upwards. like it looses the top part of the border. like this one:

http://imageshack.us/photo/my-images/507/123sb.png/

this always happens to me. i don't know why. can you check my program?

here is the code. i know it's an ugly program. but i need help.

#include<stdio.h>
#include<conio.h>
#define vid 20
#include<dos.h>

int choice;
char ans;

displaybox()
{
    int x, y;
    clrscr();
    textcolor(4);
    for (x=15; x<=67; x++)
    {
        gotoxy(x,3); cprintf("Û");
        gotoxy(x,23); cprintf("Û");
        delay(10);
    }
    for (y=3; y<=23; y++)
    {
        gotoxy(15,y); cprintf("Û");
        gotoxy(67,y); cprintf("Û");
        delay(10);
    }
}

rent(int color)
{
    float days, deposit, subtotal, total, code;
    displaybox();
    textcolor(2);
    gotoxy(35,5); cprintf("INSTRUCTIONS:");
    gotoxy(19,9); cprintf("Enter the number of the Video of your choice.");
    gotoxy(19,10); cprintf("Read User Agreement for further Information.");
    gotoxy(43,18); cprintf("Proceed [Y/N]?: ");
    scanf("%s",&ans);
    gotoxy(61,18); cprintf("");
    if((ans=='y')||(ans=='Y'))
    {
        a1:
        displaybox();
        textcolor(3);
        gotoxy(35,5); cprintf("List Of Videos");
        gotoxy(39,6); cprintf("Page 1");
        gotoxy(18,8); cprintf("[101] Ironman");
        gotoxy(18,9); cprintf("[102] Titanic");
        gotoxy(18,10); cprintf("[103] Robocop");
        gotoxy(18,11); cprintf("[104] Jurassic Park");
        gotoxy(18,12); cprintf("[105] Insidious");
        gotoxy(18,13); cprintf("[106] American Pie 1");
        gotoxy(18,14); cprintf("[107] American Pie 2");
        gotoxy(18,15); cprintf("[108] American Wedding");
        gotoxy(18,16); cprintf("[109] American Reunion");
        gotoxy(18,17); cprintf("[110] Transformers");
        gotoxy(42,8); cprintf("[111] The Hangover");
        gotoxy(42,9); cprintf("[112] Titanic");
        gotoxy(42,10); cprintf("[113] Robocop");
        gotoxy(42,11); cprintf("[114] Jurassic Park");
        gotoxy(42,12); cprintf("[115] Insidious");
        gotoxy(42,13); cprintf("[116] American Pie 1");
        gotoxy(42,14); cprintf("[117] American Pie 2");
        gotoxy(42,15); cprintf("[118] American Wedding");
        gotoxy(42,16); cprintf("[119] American Reunion");
        gotoxy(42,17); cprintf("[120] Transformers");
        gotoxy(19,19); cprintf("[B] Previous Page");
        gotoxy(50,19); cprintf("Next Page [N]");
        gotoxy(35,21); cprintf("Enter Choice: ");
        scanf("%s",&ans);

        if((ans=='n')||(ans=='N'))
        {

            displaybox();
            textcolor(3);
            gotoxy(35,5); cprintf("List Of Videos");
            gotoxy(39,6); cprintf("Page 2");
            gotoxy(18,8); cprintf("[221] Ironman 2");
            gotoxy(18,9); cprintf("[222] Ironman 3");
            gotoxy(18,10); cprintf("[223] Avengers");
            gotoxy(18,11); cprintf("[224] Dragon Ball Z");
            gotoxy(18,12); cprintf("[225] Resident Evil");
            gotoxy(18,13); cprintf("[226] Sniper");
            gotoxy(18,14); cprintf("[227] Gullivers Travels");
            gotoxy(18,15); cprintf("[228] The Simpsons Movie");
            gotoxy(18,16); cprintf("[229] Blitz");
            gotoxy(18,17); cprintf("[230] Spiderman");
            gotoxy(42,8); cprintf("[231] Spiderman 2");
            gotoxy(42,9); cprintf("[232] Spiderman 3");
            gotoxy(42,10); cprintf("[233] Amazig Spiderman");
            gotoxy(42,11); cprintf("[234] Harry Potter 1");
            gotoxy(42,12); cprintf("[235] Harry Potter 2");
            gotoxy(42,13); cprintf("[236] Harry Potter 3");
            gotoxy(42,14); cprintf("[237] Harry Potter 4");
            gotoxy(42,15); cprintf("[238] Harry Potter 5");
            gotoxy(42,16); cprintf("[239] Harry Potter 6");
            gotoxy(42,17); cprintf("[240] Harry Potter 7");
            gotoxy(50,19); cprintf("Next Page [N]");
            gotoxy(19,19); cprintf("[B] Previous Page");
            gotoxy(35,21); cprintf("Enter Choice: ");
            scanf("%s",&ans);
            if((ans=='b')||(ans=='B'))
            {
                goto a1;
            }
        }
    }
    else {
        rent(2);
    }
getch();
}

returnvid(int color)
{
    b:
    displaybox();
    textcolor(2);
    gotoxy(35,5); cprintf("INSTRUCTIONS:");
    gotoxy(19,9); cprintf("Enter the code of the Video that you rented.");
    gotoxy(19,10); cprintf("And enter how many days rented.");
    gotoxy(43,18); cprintf("Proceed [Y/N]?: ");
    scanf("%s",&ans);
    gotoxy(61,18); cprintf("");
    if((ans=='y')||(ans=='Y'))
    {
        displaybox();
        textcolor(2);
        gotoxy(35,5); cprintf("RETURN VIDEOS");
    }
    else if((ans=='n')||(ans=='N'))
    {
        goto stop;
    }
    else {
        returnvid(3);
    }

getch();
stop:
}

list(int color)
{
    c:
    displaybox();
    textcolor(2);
    gotoxy(35,5); cprintf("INSTRUCTIONS:");
    gotoxy(19,9); cprintf("The next page contains a list of available");
    gotoxy(19,10); cprintf("videos.");
    gotoxy(19,11); cprintf("Each and every video contains a code, and");
    gotoxy(19,12); cprintf("is located at the left side of the title.");
    gotoxy(43,18); cprintf("Proceed [Y/N]?: ");
    scanf("%s",&ans);
    gotoxy(61,18); printf("");
    if((ans=='y')||(ans=='Y'))
    {
        displaybox();
        textcolor(3);
        gotoxy(35,5); cprintf("LIST OF VIDEOS");
        gotoxy(18,7); cprintf("[01] The Hangover");
        gotoxy(18,8); cprintf("[02] Titanic");
        gotoxy(18,9); cprintf("[03] Robocop");
        gotoxy(18,10); cprintf("[04] Jurassic Park");
        gotoxy(18,11); cprintf("[05] Insidious");
        gotoxy(18,12); cprintf("[06] American Pie 1");
        gotoxy(18,13); cprintf("[07] American Pie 2");
        gotoxy(18,14); cprintf("[08] American Wedding");
        gotoxy(18,15); cprintf("[09] American Reunion");
        gotoxy(18,16); cprintf("[10] Transformers");
    }
    else if((ans=='n')||(ans=='N'))
    {

    }
    else {
        list(4);
    }

getch();
}

agree(int color)
{
    d:
    displaybox();
    textcolor(2);
    gotoxy(26,5); cprintf("USER AGREEMENT AND INSTRUCIONS");
    gotoxy(23,8); cprintf("The following agreement will serve as");
    gotoxy(21,9); cprintf("proof that the User who will rent a video");
    gotoxy(21,10); cprintf("has agreed upon our terms.");
    gotoxy(21,11); cprintf(" ");
    gotoxy(21,12); cprintf("Upon agreeing to our USER AGREEMENT, the");
    gotoxy(21,13); cprintf("User will be given full access and the ");
    gotoxy(21,14); cprintf("privilege to rent videos from our store.");
    gotoxy(43,18); cprintf("Proceed [Y/N]?: ");
    scanf("%s",&ans);
    gotoxy(61,18); cprintf("");
    if((ans=='y')||(ans=='Y'))
    {

        displaybox();
        textcolor(3);
        gotoxy(35,5); cprintf("Blah");
    }
    else if((ans=='n')||(ans=='N'))
    {

    }
    else {
        agree(5);
    }

getch();
}

displaymain()
{

    displaybox();
    textcolor(2);
    gotoxy(35,5); cprintf("VIDEO RENTAL");
    gotoxy(26,9); cprintf("[1] Rent Videos");
    gotoxy(26,10); cprintf("[2] Return Videos");
    gotoxy(26,11); cprintf("[3] List of Available Videos");
    gotoxy(26,12); cprintf("[4] User Agreement And Instructions");
    gotoxy(26,13); cprintf("[5] Exit");
    gotoxy(26,16); cprintf("Enter Choice: ");
    scanf("%i",&choice);

    switch (choice)
    {
        case 1: rent(2);
            break;
        case 2: returnvid(3);
            break;
        case 3: list(4);
            break;
        case 4: agree(5);
            break;
        case 5:
            break;
        default: gotoxy(35,19); cprintf("Invalid choice");
        delay(200);
    }
}

main()
{
    while (choice!=5)
    {
        displaymain();
    }
}

I don't have your compiler (Turbo C) so I can't test your program, but the cause is normally because you are attempting to write more to the screen than the screen can hold, so the operating system scrolls the screen up to make room at the bottom to add more text. Suggest you start commenting out some of those cprintf() lines until you find where the screen stops scrolling up, then you will know what line is causing it.

Oh okay. thank you. I'll go try that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.