473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C program is standard C++ program?

I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?

In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.

Please advise. thanks!!

Oct 22 '05 #1
50 2982
st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?
No.

void template()
{
}

int main()
{
template();
}

is a valid C, but invalid C++. Check your favorite textbook (you do
have one, don't you?) or google for more informations on C and C++
incompatibiliti es.
In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.


It depends on what you call a "C++ library".

extern "C"
{
void f();
}

Is this a "C++ library"? If yes, then a C program can use some C++
libraries. Your question is too vague.
Jonathan

Oct 22 '05 #2
In comp.lang.c++ st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?
In most cases, yes, but there are a few cases where this is not true.
For example, if a C program declares identifiers that are now C++
keywords but that are not C keywords. TC++PL has a section on this
topic.
In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.


True.

--
Marcus Kwok
Oct 22 '05 #3
> In comp.lang.c++ st******@gmail. com wrote:
In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.

In comp.lang.c++ Marcus Kwok <ri******@gehen nom.net> wrote: True.


After reading Jonathan's post, I will amend this to mean the standard
C++ libraries, e.g., the STL.

--
Marcus Kwok
Oct 22 '05 #4
<st******@gmail .com> schrieb im Newsbeitrag
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?
No. Not every C program is also a valid C++ program. "new", "class" or
"template" to name only a few, are valid identifiers in C, but they are
reserved words in C++. So any C program using one of these identifiers is
not a valid C++ program. Also

void foo();
int main() { foo(1); }

is legal in C, but not in C++
In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.


Just that you can use C libraries in C++ does not imply that C is a subset
of C++. You can also use Pascal or Fortran libraries in C++, but that is no
reason to think that every Pascal or Fortran program is also a C++ program.

Heinz
Oct 22 '05 #5
st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?

[snip]

int main()
{
char a[3] = "foo";
return 0;
}

It is legal in C, but not in C++.

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Oct 22 '05 #6
st******@gmail. com a écrit :
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?
No, it's not

http://david.tribble.com/text/cdiffs.htm

Unfortunately, this link seems to be down at the moment.
Maybe, more information here :

david at tribble dot com
In a C++ program, we can use standard C libraries. However, we cannot
use C++ libraries inside C program.


Correct.

--
C is a sharp tool
Oct 22 '05 #7
st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?


It is a grossly erroneous statement. C and C++ are different languages.
There are countless C programs that are not C++ programs.
Oct 22 '05 #8
"Martin Ambuhl" <ma*****@earthl ink.net> wrote in message
news:F8******** ********@newsre ad3.news.atl.ea rthlink.net
st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?


It is a grossly erroneous statement. C and C++ are different
languages. There are countless C programs that are not C++ programs.


"C++ was developed from the C programming language and, with few exceptions,
retains C as a subset."
Bjarne Stroustrup, The C++ Programming Language, 3rd ed., p. 8.
--
John Carson

Oct 22 '05 #9
John Carson wrote:
"Martin Ambuhl" <ma*****@earthl ink.net> wrote in message
news:F8******** ********@newsre ad3.news.atl.ea rthlink.net
st******@gmail. com wrote:
I want if "a C program is a standard C++ program, but not vice versa"
is a correct statement?


It is a grossly erroneous statement. C and C++ are different
languages. There are countless C programs that are not C++ programs.


"C++ was developed from the C programming language and, with few
exceptions, retains C as a subset."
Bjarne Stroustrup, The C++ Programming Language, 3rd ed., p. 8.


This may have been the intent; however, Martin's statement still is
true as C++ semantics differ from C89 in many points.
C99 introduced enough additional non-trivial differences which cannot
be easily overcome. The C standard does not make any claim w.r.t. C++
compatibility, even though there may be a rationale saying exactly
that. I do not own the C++ standard, so I cannot say anything from
this point of view.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Oct 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
1390
by: Pie | last post by:
I like to have my program (running on my home machine) email me (wherever I am) whenever it reaches a certain mile-stone (finishes a phase of the simulation or runs into an interesting path in the simulation). I just like add the feature so it can email me the partial results. Is there a source code for something like this I can add to my program? Do I need an SMTP server code or can I use my current SMTP ISP smtp server to email myself?...
11
2598
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >> Fork(MyProgram3, SomeFile); If not would this be something of interest to others? Thanks in advance,
92
9845
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if someone helps me... Urgent - Please reply soon ! Thanks, Raghu
50
2062
by: strutsng | last post by:
I want if "a C program is a standard C++ program, but not vice versa" is a correct statement? In a C++ program, we can use standard C libraries. However, we cannot use C++ libraries inside C program. Please advise. thanks!!
13
2436
by: robinsonreyna | last post by:
Hi everyone Is it possible to write a program which do not have a main() function. The program should compile and run. Please give sample code to do this.
20
2610
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine when you give it 2 or more words, but when there's only 1 word the results vary depending on whether it's on Windows or Linux: under MSVC it displays no output (as it should); under gcc/Linux it instead gives "Segmentation fault". Any ideas...
37
5039
by: Vince C. | last post by:
Hi all. I've installed Bloodshed Dev-C++ on a Windows 2000 SP4 machine. I'm using MinGW 3.4.2. I'd like to temporarily disable standard functions to write to stderr, i.e. for instance redirect stderr to a temporary file (or /dev/null but is there an equivalent under Windows? Is it "nul:") and then to *restore* the default stderr so that standard library functions that write to stderr produce output again.
16
3403
by: Knute Johnson | last post by:
I'm trying to write a C wrapper to run a Java program. I need to distribute a CD with the Java runtime, my application and a C startup program. I've put the C wrapper program, my java app and the runtime directories in the same directory. It will run under MS XP or maybe Vista. I'm using MS Visual C++ Express 2005 for a compiler and I tried using the _execl and _spawnl functions. These all give me assertion errors and file not found...
2
19338
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how we set about doing that. Every program starts with a specification, this may be a several hundred page document from your latest client or one small paragraph from your professor and pretty much anything in-between. The specification is very...
0
8435
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
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 we have to send another system
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.