Cannot find sleep function
i'm new at C Programming (i learned c++) i want to create a process with windows.h
at first i just want to start my main programm that creates a process ( --> starts an other programm)
that's my code, but it doesn't really work, i removed every unnessasery line of code but "void sleep(700)" (or "sleep (700)" for testing if the windows methods work, but i get an error, that "sleep" cant be found.
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
void main()
{
//bool ret;
//startupinfo stupi开发者_运维问答nfo;
//prozess_information pro2info;
//Getstartupinfo (&stupinfo);
//createprozess(null, "C:\\bsss10\\betriebssystemePRA1.exe", null, null, false, create_new_console, null,
// null, &stupinfo, &pro2info);
sleep (700);
cout<< "hello";
}
thanks in advance
C (and C++) is case sensitive - sleep
should be Sleep
. Similar issues (and spelling) with your commented-out code.
It should be (Note the capital S)
Sleep(700);
See the documentation
You have simalar issues with the rest of your code:
- startupinfo should be STARTUPINFO
- prozess_information should be PROCESS_INFORMATION
- Getstartupinfo should be GetStartupInfo
- createprozess should be CreateProcess
First of all, void main
should be int main
and it should return 0;
at the end. Then, it's "process" not "prozess", C++ is case sensitive, so you should use CreateProcess
, and you're also missing capitalization on the other functions.
Here's a working code sample that does what you want. (void main there too, but honestly, you should use int main
for standard compliance). Read more about creating processes here.
精彩评论