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 8 years ago.
Improve this question
Here is my code:
#include<iostream>
#include <windows.h>
using namespace std;
int main(){
ShellExecute(0, 0, L"www.ldjgsdoij.com", 0, 0 , SW_SHOW );
int i;cin>>i;
return 0;
}
How to open this web www.ldjgsdoij.com after 15 minutes even if the client
has runned exe file and closed it?
you can use C++11 Chrono functions for time.
see also Stackoverflow answer How to create timer events using C++ 11?
I think the best way it to use Schedule Tasks in Windows or Cron in Linux
For open URLs see the following answer on open browser window
Related
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 months ago.
Improve this question
I want to create a C or C++ program that automates some things for me.
The idea is as such: I run the program ./a.out and sit back and watch as it opens up three or four new terminal windows and runs various UNIX commands. Is there a way to do this?
I am on a MacBook.
As the comments point out, this is probably best accomplished by a shell script. However, you can execute shell commands from C with the system(3) standard library function. To open a terminal, just run a terminal with a particular command. For example:
system("xterm -e 'echo hello; sleep 5'");
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 have written a console application in C++ and I need to read the file that is opened with my console app:
right click on txt file
select open with
choose my console application
then I want to read that .txt file. how?
my source code
You just need to declare arguments to your main like this:
int main(int argc, char *argv[])
{
...
}
And the file path will be passed as one of the argument. If you open multiple files, it will run one process per file.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm building an GUI application.
When there is an issue and something happens, I can log the issue and present it to the user. If the error is FATAL, then the app quits and doesn't show anything. If it is ERROR, then I just present the issue to the user.
My question is in some code like this:
char* data = static_cast<char*>(malloc(size));
if (!data)
{
// What to put for errorlevel?
log(ERRORLEVEL, "failed malloc");
}
, which is a failed malloc, should it be FATAL or ERROR?
I had to put a 0 in the title because stackoverflow wouldn't let me have "Error" in the title.
Like this person said, if your app is known to use lots of memory and failed allocation is recoverable, then carry on.
Else if your app doesn't allocate many large buffers, than I would crash the app.
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 6 years ago.
Improve this question
Just as you see in the title? I have been confused about that for a long while.
In many windowing systems, a console window is opened up when your program starts executing. When your program stops executing the window disappears. This regardless to any output sent to the console.
If your program is quick, the console will "flash" by.
If you want your console window to stay for a while, you will need to pause execution. My idiom is:
std::cout << "\nPaused. Press Enter to continue.\n";
std::cin.ignore(10000, '\n');
I don't use system("Pause") because not all operating systems have a Pause command.
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 7 years ago.
Improve this question
I'm new to Raspberry Pi.
I want to run some c++ code (for GPIO controls) on apache webserver on my RPi. I've tried creating a .php file and opening it with browser, it was successful. It was a basic LED function and turned it on.
Can I do it with C++ ?
As far as I know there are some libraries you can use to control the GPIO, but I prefer writing directly to /sys/...
In bash you can do it like this:
echo "out" > /sys/class/gpio/gpio17/direction
echo "1" > /sys/class/gpio/gpio17/value
And finally to clean it up
echo "17" > /sys/class/gpio/unexport
You can yust "translate" this to C++ using e.g. ofstream:
//Set pin direction
std::ofstream out("/sys/class/gpio/gpio17/direction");
out<<"out";
out.close();
//Set pin value
out.open("/sys/class/gpio/gpio17/value");
out<<"1";
out.close();
//Cleanup
out.open("/sys/class/gpio/unexport");
out<<"17";
out.close();