I wrote a program that displays a sine wave and needed to add some colour to it. First I guess I’ll explain what the program is and what I did I guess.
Basically I have an array with 41 elements and have a function which places blank spaces,
" ", in every element of the array and places a "|" symbol in element 20 representing the axis. Then I have a function that calculates where in the array to place a "+" symbol which represents the sine wave, and returns the position of where in the array to place it (eg. element 10). It then calls another function which gets this value and actually places the "+" symbol in the array. Then I have another function which uses the insline() function to drop all the lines down one line and then it prints the array elements one by one (we don't just print the entire array using %s) on the top of the screen until the end of the array. Then I call my first function again to place all blanks and the axis in the array (clearing the "+" point). Then the program calculates the next point again, places it in the array, prints it, clears the point in the array and does this again and again and again displaying a sine wave on the screen.
I have to now add color to this program using Turbo C's textattr() function along with textbackground() and textcolor(). I saw an example of it used in a simple program that uses cputs to print a line of text in a certain colour but nothing to do with arrays, and how to have certain array elements to be certain colours.
I have to use a different colour for the background (the spaces, " "), for the "+" symbol and the "|" symbol.
If anyone could help me out or show me some code using arrays or something that'd be great.
Thanks