Implement Scrolling text in C

I was asked this question in one of my interviews with a MNC recently. The question was

"We need to display a screen in which a text scrolls at the bottom of the screen and the remaining screen is empty . How would you accomplish this in C ? What data structures would you use ..??"

Any ideas please ...!

Assuming this is a console application, you could print new lines some 24 times, which puts you at the bottom.

The string to be printed gets stored on fixed size array/vector of 81 chars (\0 terminated at position 81), which gets updated by some feeding routine. This could potentially come from a socket, typing, a file, calling process, etc...

At feeding time (timer callbacks, when file changes, socket buffer not empty, whatever), you then need to rotate text one char at a time. Assuming rotation is right to left, copy all chars from 1 (not 0) till 80 to i-1 preceding position. Write the new char on position 80.

The key graphical trick here would be to terminate your printf with \r instead of \n. \r is a modifier for return carriage: cursor returns to column 0, and will not go to the next line. That allows re-print of the same line.

How To Scroll Your Text, How To Scroll Your Text. Code: [View]. #include <string.h> #include <conio.h> # include <ctype.h> #include <windows.h> int main(int argc, char� CSS Scrolling Text — using the CSS animations; This page outlines both methods and explains the pros and cons of each method. HTML Scrolling Text. You can create scrolling text using the HTML <marquee> tag. Below is an example of using the HTML <marquee> tag to create scrolling text. See HTML Scrolling Text for more examples.

You have to shift all the characters to right side of the screen in every iteration. You can use memmove for this.

1. create a buffer of the required size based on the horizontal space in the screen 
2.print required the number of '\n' to go to the bottom of the screen
    while(1)
    {
        3.add appropriate delay
        4./*use memmove to shift all the char to right side of screen*/
        memmove(buffer+1, buffer, horizondal_size - 2);

        5.add the new character to the starting of the buffer. add '\0' to the last position in the buffer (horizondal_size - 1)

        6./*print the buffer with carriage return, then  flush the output*/
        printf("%s\r",buffer);
        fflush(stdout);

}

Turbo C / C++ - TSR Program for Scrolling Text, I have given here a sample program for TSR which stands for Terminate and Stay Resident. It is easy to implement but you need to know about interrupt service� <MARQUEE HEIGHT=75>This is my scrolling text</MARQUEE> c. Behavior – the “Behavior” attribute creates a certain movement type for the text concerned by this tag (different behaviors are: scroll, slide, alternate). Classic scroll means the text is infinitely scrolling. Slide means the text is scrolling up to a point and then stays in place.

first question is good..but it doesnt provide as much info.

there are may other ways..but i m telling you that u can make this in BGI Graphics used in Borland Compilers...

you can do following:

Simple just put a narrow bar(length is less then height of screen) at the right side of the screen..and then u have to enable Mouse pointer by Using Interrupt...one more thing the color of the scroll bar should be different from background...and now take the mouse pointer to the bar and just apply getPixel(x,y) func. (here x and y are coordinate of mouse pointer).. it will give u the color of that perticular pixel and compare it with ur color of the scroll bar...if it matches then u got the scroll bar..and u can move upward and downward ...

and u can use Linked List in this...

if u need any help with BGI..let me know..thanx...

Display circularly scrolling text on the LCD, The aim of my experiment is to display circularly scrolling text received D:\c> type lcd.c #include <stdio.h> char text[17] = "Hello Good World"; So this went from idea/design to implementation and test in less than 5 minutes. When I had to make it in my C end-of-year project around 3-4 years ago, I remmber that I used Two-Sided Linked List to support forward and backward scrolling. Vert and Horz implementations. How does it implements : each "Page" is a diffrent node in the Linked-List which saves pointer to previous page and next page. setting currsor position is

Making a number of assumptions of which you should make the interviewer aware or ask them about:

Place the text in a circular buffer, from the current index print n characters where n is the console width. Print a '\r' to return to the start of the same line. After a time interval, increment the buffer index and repeat.

So the data structure they may have been angling for is a circular or ring buffer

Without any console library other than stdio, you would get to the bottom of the blank screen simply by printing h newlines, where h is >= the console height

How to put scrolling text into your website pages, Check these methods and you'll have scrolling text in the website. Click on Install Now. c. Click on Activate. d. Check whether the plugin is part of widely known method of implementing scrolling text is to use HTML code. Scrolling text in C. Ask Question Asked 9 years, 3 months ago. Active 1 month ago. Viewed 12k times 0. I would like to scroll a text continuously in the screen.

When I had to make it in my C end-of-year project around 3-4 years ago, I remmber that I used Two-Sided Linked List to support forward and backward scrolling. Vert and Horz implementations. How does it implements : each "Page" is a diffrent node in the Linked-List which saves pointer to previous page and next page. setting currsor position is pure math calcs.

I'm sure that it is not the best way, but it is a way.

Hope that it helped,

Ran.

Scrolling a Screen Buffer's Window, The SetConsoleWindowInfo function can be used to scroll the contents of a C Copy. #include <windows.h> #include <stdio.h> #include� So in this article I will scroll the text using the timer control. Use the following procedure to create this. First of take the control from the toolbox to design the window. In this article I have taken two buttons, one label and one timer control to implement the marquee in C#. Now enter C# code for the Left to Right button click event, as in:

Scrolling, In computer displays, filmmaking, television production, and other kinetic displays , scrolling is sliding text, images or video across a monitor or display, vertically or horizontally. "Scrolling," as such, does not change the layout of the text or pictures but An early implementation of such behavior was in the "Star7" PDA of Sun� To implement scrolling in an edit control, you can use the automatic scrolling styles discussed in Edit Control Types and Styles, or you can explicitly add scroll bars to the edit control. To add a horizontal scroll bar, use the style WS_HSCROLL; to add a vertical scroll bar, use the style WS_VSCROLL .

Solved: Lab #8 (Option 1): Implementing A Scrolling Displa , C Program: Implementing a Scrolling Display Lab #8 (Option 1): Implementing a Scrolling Display Problem Summary You are. Show transcribed image text� C/C++; Windows User Interface Programming; Instructions Processing the WM_CREATE Message. Scrolling units are typically set while processing the WM_CREATE message. It is convenient to base the scrolling units on the dimensions of the font associated with the window's device context (DC).

scrolling text message - embedded C, I made various LED matrix scrolling message circuits. Now I am trying to simplify the algorithm, and shorten the source code. Here's the old�

Comments
  • Horizontally or vertically? Fixed text or continuously changing text? ISO C library only or a specific console API? Is this even a console question or a GUI? More context required perhaps.
  • That question is poorly stated and almost impossible to answer without some context, such as, what kind of UI environment the program runs in (Unix, Windows, Curses?). I'd be somewhat surprised to find that kind of question on a large corporation's interview repertoire.
  • Yes, it's a good question, because a part of the interview might be to determine the ability of the candidate to interact with the business users to help clarify requirements, !before! answering the question...
  • horizontally from right to left at the bottom of the screen
  • This is a console application using std C library. It is for text from a file .