473,472 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why is the source file extension cpp or c

3 New Member
Why we are saving a file as .cpp or .c
Nov 12 '08 #1
3 1977
JosAH
11,448 Recognized Expert MVP
Why we are saving a file as .cpp or .c
It's just a convention: .cpp for the cplusplus (c++) files and .c for the c files. Some
programs rely on it.

kind regards,

Jos
Nov 12 '08 #2
r035198x
13,262 MVP
The .cpp is usually used for c++ source files while the .c is used for C source file.
Note though that most compilers have flags to tell them to compile as C or C++ so the extension is really just aesthetic.

EDIT: Looks like Jos just got a new (faster) keyboard.
Nov 12 '08 #3
Banfa
9,065 Recognized Expert Moderator Expert
Note that while C tended to use just .c and .h for it's file extensions there are many other extensions in use in C++ on top of .cpp, for instance .cxx, .hpp, .hxx, .cc to name a few.

The extension is really only for your personal use, for instance some people use .hpp for C++ headers, in the same way that .c for C source became .cpp for C++ source they transformed .h for C headers to .hpp for C++ headers.

I don't I still use .h for all (well most) headers. On the other hand I do use .hxx (or occasionally .cxx) when I am create a template class (so I have a visual clue from the file name).

The extensions you use are your own choice. However most compilers by default compile .c as C and .cpp as C++, as r035198x says this can normally be over ridden by compiler switches (and I have done that to force C++ compilation on some auto generated C source).
Nov 12 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Henrik Weber | last post by:
Hi. I have tried to add pychecker as an extension to pythonwin. Now I can have pychecker check the source file that is currently open in the editor with a single keypress. If someone is...
17
by: Milos Prudek | last post by:
Hi, is it technically possible to distribute a python project as a closed source, i.e. encrypted? I believe that *.pyc files do not work without *.py sources... and they can be easily...
188
by: Ilias Lazaridis | last post by:
I'm a newcomer to python: - E01: The Java Failure - May Python Helps? http://groups-beta.google.com/group/comp.lang.python/msg/75f0c5c35374f553 - I've download (as suggested) the python...
2
by: RSB | last post by:
Hi Every one, I am currently using Visual Studio .Net and trying to open a project from SourceSafe and once i open the project for the first time i get the following error/warning... "The...
6
by: shr | last post by:
Is there any way by which I can display the source of a html page using the 'view:source' command, in an iframe?? I tried using this viewer.location = "view-source:" + viewer.location.href; where...
9
by: Peter Oliphant | last post by:
It occured to me that C++, C# and VB (ok, and J#, are you happy now? : ) are becoming so close that it makes sense to have a 'langauge' that allows mixing these in the same source! That is, if...
11
by: mistral | last post by:
How to deal with source code? What format need be source files to compile? I have source code on html pages, or in .txt format (this is assembler, not c, but there is no big difference, i think)....
1
by: Sunshine192 | last post by:
Hi, I'm still kinda new to PHP so I could do with some advice. I'm using the code below to select and show a random image from a folder of images. rotate.php <?php // Make this the relative...
34
by: mr.polik | last post by:
Is it legal to do something like this: #include "x.c" in other source file? And is it good idea? Thank you in advance for your answers, Igor.
13
by: Seb | last post by:
With php I can simply append a s to the file extension, eg. .phps and if the user request the file the source will be shown in the browser. Is there a semilar functionality for aspx pages? ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.