Reputation: 1393
I'm using GNU GCC compiler in Code::Blocks on Windows. Why doesn't sleep(seconds) work here? I've tried it using library and it works fine. Thanks.
Edit: By "doesn't work" I mean, doesn't compile. Sorry.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]){
char * c = (char *) malloc(sizeof(char)*50);
if(--argc>0){
printf("POTATO: \n");
while(argc>=1){
printf("- %s\n", argv[argc]);
sleep(10);
argc--;
}
printf("\n");
}
printf("A\n");
scanf("%s", c);
printf("What you wrote: %s\n", c);
scanf("%s", c);
return 0;
}
Upvotes: 2
Views: 4428
Reputation: 64
because command line argument argc is 1. so if condition is not working, use print statement before if() condition.
Upvotes: 0
Reputation: 70931
Assuming "doesn't work means "doesn't compile":
sleep()
is IX'ish. The appropriate win32 call would be Sleep()
. The difference is that the latter takes ms, but s, as sleep()
does.
To have portable code writing your own wrapper like this: https://stackoverflow.com/a/14818830/694576 might help.
Upvotes: 4