Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using C++ files in C project

Tags:

c++

c

Just out of curiosity: Is there a way to use C++ files in C projects? With files I mean the ability to access functions from header files and libraries and use them in your own projects for problems that have already been solved.

like image 468
Frank Vilea Avatar asked Aug 12 '11 15:08

Frank Vilea


People also ask

How do I add a .C file to a project?

In the Solution Explorer, right-click the Source Files folder and select Add > New Item. In the Add New Item window, select C++ File (. cpp).

Can you include a .C file in C?

The extension of the file does not matter to most C compilers, so it will work.

What is the use of C files?

Why files are needed? When a program is terminated, the entire data is lost. Storing in a file will preserve your data even if the program terminates. If you have to enter a large number of data, it will take a lot of time to enter them all.

What is .C file in C?

A file with the . C file extension is a plain text C/C++ source code file. It can both hold an entire program's source code in the C or C++ programming language, and be referenced by other files from within a C project.


1 Answers

Yes, it is possible to mix C and C++ if you're careful. The specifics will depend on what compiler, etc. you're using.

There's a whole chapter about it at the C++ FAQ: http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html.

like image 153
Oliver Charlesworth Avatar answered Sep 22 '22 14:09

Oliver Charlesworth