Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

So I want to know how to open *.cpp file under Microsoft visual C++

Status
Not open for further replies.

bareedon

Technical User
Jul 8, 2001
28
Just now I instlled Microsoft Visual C++ ver 6 in my Win2k pro station because Turbo C++ dos not work in win2k pro ....But I never work with visual C++ befor . So I want to know how to open *.cpp file under Microsoft visual C++ also, Is there any changes need to be done in the porgram it self. like the program below which I wrote it in Turbo C++ what shall I need to change ?

#include<conio.h>
#include<iostream.h>
#include<stdio.h>
int fact (int p)
{
int factp =1;
while (p!=1)
{factp*=p;
--p;
}
return factp;
}

void main()
{
char ch;
int factp,factr,factd,cr,pr,p,r;
B: clrscr ();
cout<<&quot;type the p number: &quot;;cin>>p;
cout<<&quot;Type the r number: &quot;;cin>>r;
factp=fact(p);
factr=fact(r);
factd=fact(p-r);
pr=factp/factr;
cr=pr/factr;
cout<<&quot;The value of pr is : &quot;<<pr<<endl;
cout<<&quot;The value of cr is : &quot;<<cr<<endl;
cout<<&quot;The value of factp is : &quot;<<factp<<endl;
cout<<&quot;The value of factr is : &quot;<<factr<<endl;
cout<<&quot;The value of factd is : &quot;<<factd<<endl;
cout<<&quot;endl<<&quot;please Type y to contnue or n to stop &quot;;
ch=getch();
if((ch=='y'))||(ch=='Y'))
goto B;
}
 
Well, when VC++ is installed you can normally open a .cpp by clicking on it. OTOH, you need to create a new project (console in this case) and include the files from the old project via projekt/add to project/files in order to work properly. At a quick glance everything will work other than void main() and clrscr() and a couple of syntax errors which I suspect Turbo C++ wouldn't like either, but why not just compile and see? You need int main() and you can clear the console screen with system(&quot;cls&quot;); Using goto for a loop like this is not something I'd do, though... :) Hope that this helped! ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top