How to make program waiting in c++ [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I need to make program wait for some time until continue. I tried: system("stop") but console output was:
" 'stop' is not recognized as an internal or external command, operable
program or batch file.". I need answer in c++. Answers in Is there a decent wait function in C++? doesn't work.

Following makes your program stop. At least for the next year or so. Roughly. Bonus: Its portable and doesn't drain your laptop's battery.
#include <chrono>
#include <thread>
int main() {
using namespace std::chrono_literals;
std::this_thread::sleep_for(8760h);
return 0;
}

Related

How do I show an image in the terminal in C++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to be able to just show an image along with some text. kind of like
#include <iostream>
using namespace std;
int main()
{
(image command)
cout<<"Hello World!\n";
}
There is no standard way in C++ to display images.
On some operating systems, there are APIs which allow creation of graphical user interfaces. GUIs can draw images. In order to use such API, the first step is to figure out which system you are writing the program for. Next, you can read the documentation of that operating system.

How to change bell sound ("\a") in windows 10 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was just wondering is there any way on windows 10 to change bell ("\a") sound?
(I'm using C++)
There is a method to modify the sound of beep in Windows 10 but not by using \a but by using Beep()
#include<stdio.h>
#include<windows.h>
main()
{
Beep(600,600);
}
Function parameters Beep(Freq_in_Hertz, Time_duration_for_sound);
If you want to stick with \a, you may be able to modify its sound by going to sound settings and change the alert sound.
Source

How do I convert EPOCH time to a time format (hh:mm) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have some EPOCH time values in a txt file which I need to read in then convert to a date and time. For example:1383260400. However for a particular function I would like to output only the time, in the format HH:MM. I have done my research but nothing seems to work. I tried the strftime fucntion but it does not work.
I would therefore like to know how this can be achieved.
I am kind of new to C++ so I am unfamiliar with time functions.
Thanks in Advance
You can use the C/C++ functions that utilize time_t:
#include <ctime>
#include <iomanip>
#include <iostream>
int main()
{
std::time_t secsSinceEpoch = 1383260400;
std::cout << std::put_time(std::localtime(&secsSinceEpoch), "%H:%M") << std::endl;
return 0;
}
Have a look at http://en.cppreference.com/w/c/chrono/time_t and http://en.cppreference.com/w/cpp/io/manip/put_time for more information.

How To Set Up Timer In C++? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm new to C++ and currently I'm using Code::Blocks to run my code. So, I wonder if i can set up timer until a code is executed because i need timer to make my program looks better. Any answers is accepted ^^
I wrote a timer class long ago. You can find the complete code on Github here: timer
It is a complete example with Makefile as well.
Note: You will need the ability to compile C++11.
You can create a class for this purpose. In constructor and destructor get the current time. You only need to subtracts them to get the elapse time of each functions including main.
http://en.cppreference.com/w/cpp/chrono

I want to make a C++ program that moves files [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am a fairly new C++ programmer and I am trying to set up a program that moves 2 files into a different location. How do I do this?
Under Windows, there is an API just for that purpose, the MoveFileEx() function.
To use it, start with:
#include <windows.h>
And then you can simply do something like this:
BOOL result = MoveFileEx("C:\\dir\\myfile.txt", "D:\\another\\directory\\output.txt", MOVEFILE_COPY_ALLOWED);