473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

The Command Prompt

I did a little fun program in C++ for the guys at work that picks random numbers for their Nascar pool. The random numbers are printed each on a new line and it always goes over the default viewing area which is annoying to me.

Is there something like the SetWindowPos function for the command prompt?

If I could give it some coordinates to follow when executed or even have the window go full screen.

Thanks-a-bunch,
James
Jun 6 '07 #1
7 2597
sicarie
4,677 Expert Mod 4TB
Just to clarify - you are trying to resize the console window that the random numbers are output to?

What is your OS?
Jun 6 '07 #2
AdrianH
1,251 Expert 1GB
Hazerding a guess, I'd say it is Windoze given the reference to SetWindowPos().

At the command line, type start /?. I think that is what you are looking for.


Adrian
Jun 7 '07 #3
This is just a plain C++ command prompt program. Nothing special. I was just asking about the SetWindowPos because its the closest thing I could find to solve the problem. SetWindowPos works for windows applications only I think.

Found this in an old C for Dummies book from a long time ago. Works well enough but I question the randomness of the random numbers.

Here's the code.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>    
  4.  
  5. #define DRIVERS 43    
  6. #define PICKS 43        
  7. #define DELAY 1000000    
  8.  
  9.  
  10. int rnd(int range);
  11. void seedrnd(void);
  12.  
  13. void main()
  14. {
  15.     int numbers[DRIVERS];    
  16.     int i,b;
  17.     unsigned long d;    
  18.  
  19.     printf("  N A S C A R  P O O L \nSRANDOM NUMBER GENERATOR\n\n");
  20.     seedrnd();        
  21.  
  22. /* initialize the array */
  23.  
  24.     for(i=0;i<DRIVERS;i++)    
  25.         numbers[i]=0;
  26.  
  27.     printf("Press Enter to pick this week's numbers:");
  28.     getchar();
  29.  
  30. /* draw the numbers */
  31.     printf("\nHere they come: \n\n\n");
  32.     for(i=0;i<PICKS;i++)
  33.     {
  34.         for(d=0;d<=DELAY;d++);    
  35.  
  36. /* picks a random number and check to
  37. see if it's already been picked */
  38.  
  39.         do
  40.         {
  41.             b=rnd(DRIVERS);    
  42.         }
  43.         while(numbers[b]);    
  44.  
  45.         numbers[b]=1;        
  46.         printf("%i \n",b+1);    
  47.     }
  48.     printf("\n\nGood luck in the drawing!\n");
  49.     printf("\n\nPress the enter key to exit.\n");
  50.     getchar();
  51.  
  52. }
  53.  
  54. /* Generate a random value */
  55.  
  56. int rnd(int range)
  57. {
  58.     int r;
  59.  
  60.     r=rand()%range;        //spit up random num.
  61.     return(r);
  62. }
  63.  
  64. /* Seed the randomizer */
  65.  
  66. void seedrnd(void)
  67. {
  68.     srand((unsigned)time(NULL));
  69. }
  70.  
Jun 7 '07 #4
Silent1Mezzo
208 100+
This is just a plain C++ command prompt program. Nothing special. I was just asking about the SetWindowPos because its the closest thing I could find to solve the problem. SetWindowPos works for windows applications only I think.

Found this in an old C for Dummies book from a long time ago. Works well enough but I question the randomness of the random numbers.

Here's the code.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>    
  4.  
  5. #define DRIVERS 43    
  6. #define PICKS 43        
  7. #define DELAY 1000000    
  8.  
  9.  
  10. int rnd(int range);
  11. void seedrnd(void);
  12.  
  13. void main()
  14. {
  15.     int numbers[DRIVERS];    
  16.     int i,b;
  17.     unsigned long d;    
  18.  
  19.     printf("  N A S C A R  P O O L \nSRANDOM NUMBER GENERATOR\n\n");
  20.     seedrnd();        
  21.  
  22. /* initialize the array */
  23.  
  24.     for(i=0;i<DRIVERS;i++)    
  25.         numbers[i]=0;
  26.  
  27.     printf("Press Enter to pick this week's numbers:");
  28.     getchar();
  29.  
  30. /* draw the numbers */
  31.     printf("\nHere they come: \n\n\n");
  32.     for(i=0;i<PICKS;i++)
  33.     {
  34.         for(d=0;d<=DELAY;d++);    
  35.  
  36. /* picks a random number and check to
  37. see if it's already been picked */
  38.  
  39.         do
  40.         {
  41.             b=rnd(DRIVERS);    
  42.         }
  43.         while(numbers[b]);    
  44.  
  45.         numbers[b]=1;        
  46.         printf("%i \n",b+1);    
  47.     }
  48.     printf("\n\nGood luck in the drawing!\n");
  49.     printf("\n\nPress the enter key to exit.\n");
  50.     getchar();
  51.  
  52. }
  53.  
  54. /* Generate a random value */
  55.  
  56. int rnd(int range)
  57. {
  58.     int r;
  59.  
  60.     r=rand()%range;        //spit up random num.
  61.     return(r);
  62. }
  63.  
  64. /* Seed the randomizer */
  65.  
  66. void seedrnd(void)
  67. {
  68.     srand((unsigned)time(NULL));
  69. }
  70.  

By C++ do you mean C? I've written a very similar program in C.
Jun 7 '07 #5
AdrianH
1,251 Expert 1GB
This is just a plain C++ command prompt program. Nothing special. I was just asking about the SetWindowPos because its the closest thing I could find to solve the problem. SetWindowPos works for windows applications only I think.

Found this in an old C for Dummies book from a long time ago. Works well enough but I question the randomness of the random numbers.

Here's the code.
Is there another question here? I've looked at the start command and discovered that it only allows you to maximise the window. If you want something else, you will have to execute a .lnk file which has the appropriate properties set.
To create and set one up:
  1. right click and drag your executable, then release.
  2. Then rename it to what you want.
  3. Right click on it and set the properties to that which you want.
  4. from your app, execute the file name though the cmd programme. Don't forget to append .lnk extention to it. I.e.
    Expand|Select|Wrap|Line Numbers
    1. system("cmd /c myexe.lnk");
Hope this helps.


Adrian
Jun 7 '07 #6
ahammad
79
If I got you correctly, the console window isn't large enough to hold all the numbers? In that case, there is a way to change that and keep it simple.

When the console pops up, click the upper left corner and go to Properties.

Click the Layout tab

At the "screen buffer size" field, type in however many lines you want in the Height field.

Click OK and Save properties.

It gets the work done without any unnecessary coding.
Jun 7 '07 #7
I got it to work using the properties dialog for the executable. I would have thought their would be some piece of C code that would do it though.

Thank You for all your ideas.
Jun 12 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: msuk | last post by:
All, I am trying to use Regasm from the command prompt and have to keep putting the full file path of where my assembley is located. Does anyone know how to set it up so wherever I run the...
3
by: Rog | last post by:
Yes, I am guessing that typing cmd in the run windows will bring up the command prompt, but not the vs.net command prompt. Is there a switch(s) for accessing the vs.net command prompt? Or...
4
by: glenn | last post by:
I keep reading all sorts of books on VS that keep telling me to click on Tools/Visual Studio Command prompt to run this program or that program. However, I do not have such a menu choice. Where is...
4
by: Thomas Johnson | last post by:
I am trying to find out how to access the VS 2003 .Net command prompt. I am trying to execute the 'csc' command against a module but have no idea where to find the command prompt. Here's a stupid...
6
by: Jwolf | last post by:
I have .net 2002 edu version and when it installed there was a shortcut to the .net command prompt. My CLR disk is scratched so I can't reinstall and so I just downloaded express. I dont know...
6
by: Shooter4Life8 | last post by:
Hi, I am having trouble figureing out the best way to open a command prompt then write lines to it in VB.NET. Currently I have this code, but it execute's too fast I think because Dim psi As...
9
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
3
by: kimiraikkonen | last post by:
Hi experts, I just want to ask a simple procedure of my simple form. My form has a input textbox and a button. I want this if you can help me: Application user types a command prompt command...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.