(C++) GUI Question

tooltiperror

Super Moderator
Reaction score
231
Code:
#include <iostream>

using namespace std;

int main()
{
	
	int thisisanumber;
	int x = 0;
    
	for (x=0;thisisanumber!=3;x++)
	{
		cout<<"Enter a guess: ";
		cin>> thisisanumber;
		if (thisisanumber<3)
		{
			cout<<"Your guess is too low. \n";
		}
		else if (thisisanumber>3){
			cout<<"Your guess is to high. \n"; 	
		}
	}
	cout<<"You have won! \n";
	cin.get();
}

This code, obviously, asks for a random number, well not random, and then tells you if it was lower or higher, untill you guess it.

1) How do I get a random number? Whenever I try to use stuff, it doesn't work.

2) How do I make a GUI for this? Like a window with a text box and maybe a number line to choose from.

3) How do I change it into a .app?
 

Sintoras

Shaaakaa!
Reaction score
45
1) I believe theres quite a bit of stuff about this subject on the net. Using the current time as a seed is one way, still doesn't really make it random though, just more improbable to get the same pattern. I think .NET has a random class which is really quite random.
2) Visual C++ makes this easiest imo.
3) Sorry, no idea. Why would you need this?
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
> How do I make a GUI for this?

I believe including the windows.h header adds native Windows GUI elements, but it's a bitch to code (at least in C it is.).

If you use GTK+ though, you can make cross-platform GUI.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
2) Use wxWidgets, using openGL would be terrible waste of resources and time for a simple application.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top