![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
when i was taking c++ in school, i was taught that c++, by design, is a superset of c, which is to say that it contains ALL of c, plus more. and that any valid c code will compile as c++.
is this incorrect? |
|
|
|
|
|
#12 |
|
Programmer
Join Date: Apr 2005
Posts: 77
Rep Power: 4
![]() |
I actually have heard that it is generally correct, except for a few rare exception.
|
|
|
|
|
|
#13 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
well, apparently eggbert already answered that question. i guess there's just a few quirks you have to be aware of.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#14 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 5
![]() |
In your second post your command line:
root@Mikey_Iky:~# gcc -o firstC.c firstC <---- try-- gcc -o firstC firstC.c
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#15 |
|
Programming Guru
![]() ![]() ![]() |
I was not aware of that either.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#16 |
|
Newbie
Join Date: Mar 2005
Posts: 7
Rep Power: 0
![]() |
Thanks for the response every body.
First of all, its so strange. Ive worked with C++ and Ive always been instructed to use int main() It also doesnt mention anything about the header file in the code examples either. And ill give it another go with the revisions you mentioned. By the way, for any one else having similar problems, dont use 'Programming in C' by Stephen G. Kochan. I wasnt informed about any of these this that was causing me so much grief. Thanks again. |
|
|
|
|
|
#17 |
|
Newbie
Join Date: Mar 2005
Posts: 7
Rep Power: 0
![]() |
By the way, im not sure what breaks the compiler. but i think its going to work now.
|
|
|
|
|
|
#18 |
|
Newbie
Join Date: Mar 2005
Posts: 7
Rep Power: 0
![]() |
I i gave your suggestions a shot, and i recieved some interesting results.
/*my first attempt at the C programming language.*/
#include <stdio.h>
int main()
{
printf ("Programming is fun.\n"
"And programming in C is even more fun!\n"
"Although I don't purticularly care for the stupid things that they are having me write."
"\n");
return 0;
}But this piece of code /*my first attempt at the C programming language.*/
#include <stdio.h>
int main()
{
printf ("Programming is fun.\n"
"And programming in C is even more fun!\n"
"Although I don't purticularly care for the stupid things that they are having me write."
"\n")
return 0;
}firstC.c: In function `int main()': firstC.c:9: error: parse error before `return' "\n" But thanks again for all the help. |
|
|
|
|
|
#19 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5
![]() |
In the last piece of code you didn't add the semicolon after the printf() statement
You could also put all that text on one line of code :p
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#20 |
|
Newbie
Join Date: Mar 2005
Posts: 7
Rep Power: 0
![]() |
yeah, i know but i do the whole spacing thing for readablilty.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|