I just need some clarification on what my homework assignment is telling me to do.

Ok, this is the homework question:

Write a program that reads a key pressed on the keyboard and displays its code on the screen. Use the program to determine the code for the Enter Key. Then write a function named ReadOneChar() that reads a character and ignores any succeeding characters until the Enter key is pressed. The entered character should be returned by ReadOneChar()

My code:

#include <iostream>
using namespace std;

int main()
	int Key;
	cout << Key <<endl;
	return 0;

Ok, so what my code is doing right now is just prompting the user for an input, then displays the ASCII value of the input. So it works and it retrieves the value of the Enter key as needed.

What I do not understand is what the second part of the homework is asking. Can anyone clarify it for me? Is it just asking to return the first character of a string?

7 Years
Discussion Span
Last Post by jwenting

that function should take everything entered on the keyboard until the next enter, strip all but the first character from that string, and return only that first character.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.