Custom "invalid input" error message in Text-Based Game - c++

I'm new to stackoverflow and would like to thank any and all people who come across this post and gives any assistance. Sorry if this question/request seems noob-ish, I am a beginner-intermediate programmer in C++(closer to beginner I would say) but I know the basic fundamentals needed for a text-based game; however this one thing is stumping me for some reason.
Anyway, I am working on my own Text-Based Game and was looking to add a feature I saw in a video(Linked below) that when a user inputs an invalid char, or choice, would display a line of red text saying, "Previous selection was INVALID, try another from the list:" at the top of the console above the current screen/menu/submenu they were on and would stay there until the user entered a valid option. I know how to change the individual line color to red without changing the other text on the screen and how to make the error system, but how do I get it to appear at the top of my menu and stay there until the user has entered a valid option. Once I figure this out I can work on customizing it further.
Video: https://www.youtube.com/watch?v=5gBU5rptR8I #54 Seconds in the vid
Much appreciated,
the newbie,
xChubz

Clear console text (it's OS-specific, read here: How can I clear console), and simply rewrite what you had written before with your error message on top!

Not sure how to use a specific color but to clear the screen use:
system("CLS");

Related

UE4 - I want to make an ingame camera/photography mode and save the pictures

for my game project I want to include a "camera mode".
This means, that on a press of a button the current camera view gets saved in an in-game gallery.
After some search, I only found ways to save a screenshot on the disk (BP for saving Screenshot, semi functional)
, but I want the picture to be still available in my game, maybe as a texture or in a struct. So I can later use it, well in an in-world picture frame or newspaper.
I did try SceneCaptureComponent2D, but I never got that one really working and searching online got no satisfactory results.
By the way, I'm fine with C++, I'm just building my current prototype with BP for faster testing and altering.
I hope you can help me.
I would have commented on your question, but I do not have enough reputation to do so, because this answer I am providing you is more a hint on how you could do it rather than a straight solution for your problem.
Check out this repository on how to capture images with C++ during a running application which is actually meant for recording data.

Moving cursor using code and opening folder

This is a very random and maybe a bit strange question that i thought of at 3AM. I was thinking about how code could make my day to day life easier. Every morning I wake up, open chrome to the facebook conversations with my boyfriend, and write "good morning". And thats when i thought about this hypothetical project(just out of curiosity, I wouldn't use it haha): making a code that i can just run that does all of this for me.
I could have a html file that could redirect to the facebook link(https://www.facebook.com/messages/t/boyfriend_name). But how would I go on to make the code open this file, then move the mouse to where its supposed to go (the white area where the user inputs the text) then insert the text then press send?
I'm not asking for any code help as I can imagine that is too much, but my question is: could this be achievable in C++?(This is what we've been studying at school so far). If not, what coding language should I use? Is the idea achievable without a vast knowledge in computer science? If yes, have you got any sources about opening files using C++, moving cursor etc.
Note:The OS this would happen on is Windows 10
To do what you want is possible by using AutoIT and to use it from C++ you can try AutoITX for C++. With AutoIT it's possible to detect windows, move the mouse and insert text, although a web page is like a blackbox to it, so you'll have to rely on relative pixel coordinates (it might not be very robust).

Restarting a program with a key word - re looping?

So I've made a program in class for a project, this is done using C++, which is a menu system with one sub menu, to then deliver correct directions from one location to another,
this involved many else and if statements as well as a while loop. however, i'm wondering if it is at all possible to make it so if the user enters a particular string, to restart from the beginning of the program? such as a small function which is a re director to the top of the code again? so if the user messes up on the first menu, they can type 'back' in and go back to the previous menu?
it sounds easy, and its simple, but i'm having trouble with it, and don't know what the best way to approach this would be, despite how minor it is!
Any help is appreciated
thanks!

Text-to-speech from my file/database?

I've made a little alarm program that is supposed to say one of a few things. There's a similar program on macs, but I couldn't find it for Windows, so I just wrote it in C++. Right now, I'm using a text file. The format of the text file I am parsing should help you to understand how the program works:
alarmName_Wakeup //There's a prefix alarmName, so I know when one list starts and another ends.
Cock-a-doodle-doo! //One thing to say.
Get out of bed! //Another thing to say.
Hello. Would you like to buy some guava juice? //Yet another thing to say.
So, I'm basically just trying to have the alarm randomly read one of these lines of text every five minutes until the user goes to his or her computer and presses the hotkey or clicks 'Stop Alarm'. I haven't been able to figure out how to get text-to-speech from a file or a database, though. I always need to have the text pasted in notepad or something, which is really shoddy. Please, help me figure out how.
The closest I can find to what I'm looking for is Open-SAPI, which works for both Linux and Windows.

How to keep the terminal from scrolling

I am writing a simple program in C++ to be run in a terminal window. I would like the output text to be locked in position on the screen. Instead of each new line appearing at the bottom of the screen and pushing everything up, I would like to be able to change a line of text or some characters in a line of text, while keeping other lines above and below it static. I know I have seen this done in terminal, and I believe it was done with C++, but I can't find any documentation on it. I cannot even think of what this type of display might be called. My google fu has failed me; please help. If you can tell me what commands/library to use, that would be great, but even being able to tell me what commands accomplish this in a programming language other than C++ would give me more to go on than I have now.
You want ncurses, a library for displaying text on a terminal.
If you are programming for Microsoft Windows, try googling for Win32 Console Functions.