Posted on 2003-11-16
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 ;
  cout << argv[1]*1000 <<endl ;


  return 0;

Why doesn't this works ???
Question by:lapijn
LVL 48

Accepted Solution

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 ;


    return 0;

Author Comment

ID: 9758654
Thanks, works indeed.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 86
Beginner to Unreal Engine 4 5 94
show out valin of json for debugging in visaul c++ 1 41
learn programming 8 43
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

820 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