954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to run simple c++ prog from another system?

Hi,

i hve asimple c++ prog written in vc++ editor.I am able to run this in my system when i deploy it in another system which doesn't hve vc++ environment its not working the exe just closes...

can anyone just tell me how to deploy the exe into another system.

is the build in debug mode creates a problem?


please help

thanks

geeta
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

For a simple C++ program you should be able to do it even when Visual Studio is not installed in the other machine. Since you have mentioned it as simple C++ program, I assume it is a console program and that you have forgotten to include a cin statement at the end of the program. This makes the output window to close immediately after it finished its operation.

you can also use

system("pause" );


statement before the return statement to make the program pause till you press a key.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

you can also use

system("pause" );
statement before the return statement to make the program pause till you press a key.

I thought Ive read on several occasions that this should be avoided since it is bad programming :?:

JoBe
Posting Pro in Training
420 posts since Sep 2004
Reputation Points: 51
Solved Threads: 4
 
I thought Ive read on several occasions that this should be avoided since it is bad programming


If that is true, accept my appologies. Why is it bad?

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

system() function takes a lot of time to execute. There are better ways to do that which do not use cmd.com (or command.com).

c++ -- cin.ignore() will wait for user input
 or cin.get()

c -- getchar()
Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

Thanks a lot.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

Or simply have the user go to a dos prompt before executing the program.

winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 
system() function takes a lot of time to execute.

So?

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 176
 
So?

system("cls") is non-standard and doesn't work across operating systems -- for examp unix uses system("clear"), and I suppose apple uses something else. If you want to write ANSI C or C++ then you must stay clear of system() function. But you can ignore that little detail when writing small example programs for yourself that you never indend for anyone else to see.

Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

its not a win32 console app. with simple empty application...no not that...
i actually started this prog by selecting a C++ source filefrom files section in the wizard...later compiled the prog it asked tocreatethe workspace sodid taht... prog worked fine its in debug mode... as its a c++ source file the moment i created and built the prog its in debug mode...
wheni deploy it in another sys which doesn't have VS or any other .net or VC++ or vB installed.. its giving problemit just closes doen't give the o/p even i hve set the puse aslobut no luck plz help

geeta
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

Could you post your code so that we can see what are the dependencies, if there are any?

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 
Could you post your code so that we can see what are the dependencies, if there are any?

this is the prog which i hve written

#include
#include
#include
#include


void main()
{


char str[8000];
char *delemeter=NULL;
char *str2;
int strlen1;
int fileflag=0;
char *filename;
char in_file[50];
int flag=0;
char ext[6]=" ";
long count=0;
long size;
long line=0;


fstream file_in;
fstream file_out;

//get the input file
cout<<"Please enter the filename: ";
cin>>in_file;
file_in.open(in_file,ios::in);

//get the extension
cout<<"Please enter the extension: ";
cin>>ext;

cout<

geeta
Newbie Poster
4 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

Add the following code at the end of your main function.

cout << "Press any key to continue" << endl;
cin.ignore(2);


This link was posted in a previous thread and it has some other methods, that maybe better than this, so take a look at it.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You