• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C/C++ Teach yourself C++ in 21 days

Wnat a better?
Here you are.
Code:
#include <iostream>
int main() {
int a, b;
a = 0;
b = 1000000000;
while(a < b) {
	std::cout << "Hello - My name is Zonet, this is a buggy program ok?";
		a++;
		std::cout << std::endl;
	}
	system("PAUSE");
return 0;
}
test plx.

Lol, that will finnish pretty fast xD
 
zonet i told you man...
int a, b; is not C++, its C.

system("pause > nul"); looks better.

return values in small program like those, is not needed ;s.
 
You guys sounds/look like nerds x), with all the system("pause > nul");, nul ect xD
 
Not use system("PAUSE");, that is a Widnows bound feature. Use cin.get();
instead.
 
Thank you for this wonderful book thingy ;o This helped me out a lot, although i'm not very good yet :p
 
Code:
/* clock example: countdown */
#include <stdio.h>
#include <time.h>
#include <iostream>

using namespace std;

void wait ( int seconds )
{
  clock_t endwait;
  endwait = clock () + seconds * CLOCKS_PER_SEC;
  while (clock() < endwait) {}
}

             
int main() {

    cout << "Wait 10 seconds :o";

    wait(10);
    
        system("cls");
    cout << "10 seconds have now passed :o" << endl;


    
    system("pause");
}

Anyone dare to try it? :)
 
why not just sleep(10*1000);?

Because this looks waaay much more pro, and it's easy to make it take decimals also :) just change

Code:
 void wait ( int seconds )

for

Code:
 void wait (double seconds )

and then use wait(number with deciamls) instead of having to calculate through math :p
 
No, do it right or don't do it at all. Sleep is way better because it's not platform dependant too.
 
No, do it right or don't do it at all. Sleep is way better because it's not platform dependant too.

It kindof is, Sleep is the Windows function that takes milliseconds as parameter. sleep (yes, lowercase) is the Linux (unistd) function and takes seconds as parameter.
 
Because this looks waaay much more pro, and it's easy to make it take decimals also :) just change

Code:
 void wait ( int seconds )

for

Code:
 void wait (double seconds )

and then use wait(number with deciamls) instead of having to calculate through math :p

Who cares if it looks "pro"?
 
Code:
#ifndef __MINGW32
#include <unistd.h>

void Sleep(unsigned int  useconds )
{
    usleep( useconds * 1000 );
}

#else
#include <windows.h>
#endif
 
Back
Top