C++ help

Questions about programming languages and debugging
Post Reply
bubzuru
.net coder
.net coder
Posts: 700
Joined: 17 Apr 2007, 16:00
17
Contact:

C++ help

Post by bubzuru »

i need help with some C++ . here is the code

Code: Select all

#include <iostream>
#include <windows.h>
using namespace std;

 void cmd_beep(int a, int b){
 Beep(a,b);
 }

 int main(){

 cmd_beep(2222, 2222);
 
 return 0;
 
           } 
this works but how can i make it so that the user can type

Code: Select all

prog.exe cmd_beep(2222,2222)
in a cmd shell then the program will beep how can i do that ??

PopPooB
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 236
Joined: 16 May 2007, 16:00
16
Location: CandyLand
Contact:

Post by PopPooB »

couldent you just type

Code: Select all

prog
in the cmd shell if the program already beeps
96% better then all connections global
Kiss My Ass Good Bye

bubzuru
.net coder
.net coder
Posts: 700
Joined: 17 Apr 2007, 16:00
17
Contact:

Post by bubzuru »

no because that not wot i want to do :lol:

this is how its done just in case ppl want to know

Code: Select all

#include <iostream>
#include <windows.h>
using namespace std;

  
  int main(int argc , char *argv[]){
  for (int i = 0; i < argc;i++) 

  printf("arg %d: %s\n", i, argv[i]); 
  
  system("pause");
  
  return 0;
  }
      

ebrizzlez
Kage
Kage
Posts: 732
Joined: 31 Mar 2007, 16:00
17
Location: Hidden in a Buffer Protection.
Contact:

Post by ebrizzlez »

You could use cin.get(); .

In order to use that you need to make a character or string variable and pass through some parameters in the get() function call. :wink:

[EDIT] If you are making a list of indpendent programs where one program is named beep.exe the other main.exe you could make beep.exe be called simply by using the system functions, then you could pass a second parameter to call what command. This is a unusual way of programming and may cost you in the end when space comes into play.

For example: [Psuedo Code]
system(Call program name here) && Add string to program;
or
system(Call Program Name). Pass string to program;

Kinda buggy, the only reason I won't provide you with a straight answer is because there is a Google out there for probably a better method. :roll:
[img]http://i81.photobucket.com/albums/j205/ebrizzlez/4lsint1.jpg[/img]

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Post by Gogeta70 »

¯\_(ツ)_/¯ It works on my machine...

ebrizzlez
Kage
Kage
Posts: 732
Joined: 31 Mar 2007, 16:00
17
Location: Hidden in a Buffer Protection.
Contact:

Post by ebrizzlez »

Yeaa... ermm...
I forgot to mention, I was a bit tired once I woke up and rushed to school.

char variable ="prog.exe beep(222,222,222)"

or

if (varible=="prog.exe beep(222,222,222)" )

in any case, string would fit better, so you might have to make the varible into a string. But use gogeta's refrence for more help. I am still in a rush so really cant explain it in details and every piece of info you need is on that site or google. :wink:
[img]http://i81.photobucket.com/albums/j205/ebrizzlez/4lsint1.jpg[/img]

Post Reply