Question

TASK: to receive this checkpoint, you must write a simple function that displays a text message...

TASK:

to receive this checkpoint, you must write a simple function that displays a text message on the

screen. The function signature should be:

void print_to_screen(char *message);

This function should accept a string, and write each character of the string to the screen, and

increase the

current_screen_x

variable for each character printed.

You will need to maintain a pointer to the current line on the screen, as well as the position on

that line. You could do this with definitions like:

unsigned char *current_screen_line = $0400;

unsigned char current_screen_x = 0;

Implement the

print_to_screen()

function.

Now create a second function called print_newline() that advances

current_screen_line

to the next line, and resets

current_screen_x

to zero, so that printing can continue from the

next line.

Call your new

print_to_screen()

and

print_newline()

functions from your

reset()

function to print the two messages “YOURFAN operating system starting...” and

“testing hardware” on separate lines.

Test you program with the following commands:

cd ${HOME}/repo/unit3

make test3.1

please help me to solve this problem, thanks a lot!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Code you expected is made for turbo c compilers.

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

#include<windows.h>

int current_screen_x=0;
int current_screen_y=0;

void gotoxy(int x,int y)

{

COORD c;

c.X=x;

c.Y=y;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);

}

void print_to_screen(char *message)
{
int i;
for(i=0;message[i]!='\0';i++)
{
printf("%c",message[i]);
current_screen_x++;
}
}

void print_newline()
{
int y=wherey();
current_screen_x=0;
gotoxy(current_screen_x,y+1);

}
void reset()
{
char *str1="YOURFAN operating system starting....";
char *str2="testing hardware";
print_to_screen(str1);
print_newline();
print_to_screen(str2);
}

void main() {
clrscr();
   reset();

getch();

}

Add a comment
Know the answer?
Add Answer to:
TASK: to receive this checkpoint, you must write a simple function that displays a text message...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code needs to be written by KickC - Optimizing C-compiler for 6502 you must write a...

    Code needs to be written by KickC - Optimizing C-compiler for 6502 you must write a simple function that displays a text message on the screen. The function signature should be: void print_to_screen(char *message); This function should accept a string, and write each character of the string to the screen, and increase the current_screen_x variable for each character printed. You will need to maintain a pointer to the current line on the screen, as well as the position on that...

  • Write this function in c++.Use of string and <cstring> is not allowed .You are required to...

    Write this function in c++.Use of string and <cstring> is not allowed .You are required to use char* and implement the use of ** in this question . Gtest case to pass: #include "q1.cpp" #include <gtest/gtest.h> //-------------------Q1_8----------------- TEST(Question1_8, First) { char t1[]="Hello World"; char res1[] = "Hello"; char res2[] = "World"; char** r= StrTok(t1,' '); ASSERT_EQ(0, strcmp(r[0],res1) ); ASSERT_EQ(0, strcmp(r[1],res2) ); } TEST(Question1_8, Second) { char t1[]="Hello?World?OOP"; char res1[] = "Hello"; char res2[] = "World"; char res3[] = "OOP"; char**...

  • Write a c++ program in that file to perform a “Search and Replace All” operation. This...

    Write a c++ program in that file to perform a “Search and Replace All” operation. This operation consists of performing a case-sensitive search for all occurrences of an arbitrary sequence of characters within a file and substituting another arbitrary sequence in place of them. Please note: One of the biggest problems some students have with this exercise occurs simply because they don’t read the command line information in the course document titled “Using the Compiler’s IDE”. Your program: 1. must...

  • Topics: Arrays in C. For this assignment, you will write a C program that uses its...

    Topics: Arrays in C. For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it. Requirements: Your program must compile and run correctly using the gcc compiler on ale. You must write the corresponding function definitions for the following function prototypes: // set all elements of the histogram to zero void init_histogram(int histo[]); // construct the histogram from string void cons_histogram(char string[], int...

  • Consider the following C++ program. It reads a sequence of strings from the user and uses...

    Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...

  • Instructions: Consider the following C++ program. It reads a sequence of strings from the user and...

    Instructions: Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

  • MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment:...

    MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment: In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it. In this lab you will write a program to decode a message that has been encrypted using two different encryption algorithms. Detailed specifications: Define an abstract class that will be the base class for other two classes. It should have: A...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include...

    Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start: // You are given a partially complete program. Complete the functions in order for this program to work successfully. // All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters. //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT