Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,230 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,866 people online right now. Registration is fast and FREE... Join Now!




How to convert C code to C++ Code

 
Reply to this topicStart new topic

How to convert C code to C++ Code

SK-II_Maple
9 Mar, 2007 - 01:13 AM
Post #1

New D.I.C Head
*

Joined: 9 Mar, 2007
Posts: 20


My Contributions
Can somebody tell me how to convert C code to C++ codes?
10s....
User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: How To Convert C Code To C++ Code
9 Mar, 2007 - 01:24 AM
Post #2

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,026



Thanked: 35 times
Dream Kudos: 125
My Contributions
QUOTE(SK-II_Maple @ 9 Mar, 2007 - 02:43 PM) *

Can somebody tell me how to convert C code to C++ codes?
10s....



Well, I don't know if there are any tools available. But as far as I know both languages are having totally different approches. C is Function oriented where as C++ is Object Oriented. Now if you want to port the code from C to C++ [I mean real object oriented code and not just making it runnable with C++ compiler and look like C++ code] then you need to rework on design of application.

You can Identify objects and entities from C++ and rebuild the application using old logics you used in C programs.

But if you want porting programs then sorry from my side sad3.gif . I really don't know any. huh.gif
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: How To Convert C Code To C++ Code
12 Mar, 2007 - 04:49 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
What code do you want to convert?

Almost any code that compiles with C, compiles fine with C++ as well.

C++ provides some extra features which cannot be used in traditional C.
User is offlineProfile CardPM
+Quote Post

SK-II_Maple
RE: How To Convert C Code To C++ Code
12 Mar, 2007 - 10:41 AM
Post #4

New D.I.C Head
*

Joined: 9 Mar, 2007
Posts: 20


My Contributions
Let say "include <conio.h>"?

Because ".h" header is the old version..so i would like convert it to the latest...which i need to use the getch() and getche() functions...
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: How To Convert C Code To C++ Code
12 Mar, 2007 - 11:02 AM
Post #5

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,013



Thanked: 18 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
.h is a header file, not and old version.
yes getch() has been depreciated, but you can still use _getch() if you wish, it is still backwards compatable for now.
there is also cin.get();
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: How To Convert C Code To C++ Code
12 Mar, 2007 - 11:18 AM
Post #6

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
It should be noted that the conio.h library itself is platform specific, and the use of the getch() function does not conform to standards. Better to use the method mentioned by WW, or another standards compliant method.
User is online!Profile CardPM
+Quote Post

SK-II_Maple
RE: How To Convert C Code To C++ Code
13 Mar, 2007 - 11:21 AM
Post #7

New D.I.C Head
*

Joined: 9 Mar, 2007
Posts: 20


My Contributions
10s.....
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 03:17PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month