Solved

Sleep-program

Posted on 2003-11-16
2
702 Views
Last Modified: 2010-04-01
I'm trying to make a program whitch sleeps n seconds, with n the commandline-input:
//////////////////
#include <windows.h>
#include <iostream>

using std::cout;
using std::endl;

int main(int argc,int *argv)
{
  if (argc != 2)
  {
    cout << "Usage : Sleep n\nwith n: number of seconds\n" << endl ;
    exit(-1);
  }
 
  cout << argv[1]*1000 <<endl ;

Sleep(argv[1]*1000);

  return 0;
}

////////////////////
Why doesn't this works ???
Thanks.
0
Comment
Question by:lapijn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 75 total points
ID: 9758638
#include <stdlib.h>

#include <windows.h>
#include <iostream>
using namespace std;


int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        cout << "Usage : Sleep n\nwith n: number of seconds\n" << endl ;
        return -1;
    }

    int n = atoi(argv[1]);
    cout << n*1000 <<endl ;

    Sleep(n*1000);

    return 0;
}
0
 

Author Comment

by:lapijn
ID: 9758654
Thanks, works indeed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 76
FMX StringGrid1->Canvas->FillRect Problem 3 221
object oriented programming comparison 5 93
DCT of  2D array using fftw in c++ 9 132
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question