Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 25th, 2005, 1:09 PM   #11
brkstf
Programmer
 
brkstf's Avatar
 
Join Date: Feb 2005
Posts: 89
Rep Power: 4 brkstf is on a distinguished road
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?
brkstf is offline   Reply With Quote
Old Apr 25th, 2005, 1:42 PM   #12
Josef_Stalin
Programmer
 
Join Date: Apr 2005
Posts: 77
Rep Power: 4 Josef_Stalin is on a distinguished road
I actually have heard that it is generally correct, except for a few rare exception.
Josef_Stalin is offline   Reply With Quote
Old Apr 26th, 2005, 2:03 AM   #13
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Old Apr 26th, 2005, 4:59 AM   #14
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 5 lostcauz is on a distinguished road
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!
lostcauz is offline   Reply With Quote
Old Apr 26th, 2005, 2:49 PM   #15
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Apr 28th, 2005, 10:00 PM   #16
Mikey_Ickey
Newbie
 
Join Date: Mar 2005
Posts: 7
Rep Power: 0 Mikey_Ickey is on a distinguished road
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()
and the book that i am using doesnt mention anything about it, so i assumed that it was just how C was.
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.
Mikey_Ickey is offline   Reply With Quote
Old Apr 28th, 2005, 10:02 PM   #17
Mikey_Ickey
Newbie
 
Join Date: Mar 2005
Posts: 7
Rep Power: 0 Mikey_Ickey is on a distinguished road
By the way, im not sure what breaks the compiler. but i think its going to work now.
Mikey_Ickey is offline   Reply With Quote
Old Apr 28th, 2005, 10:20 PM   #18
Mikey_Ickey
Newbie
 
Join Date: Mar 2005
Posts: 7
Rep Power: 0 Mikey_Ickey is on a distinguished road
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;
}
this returned the same big error as before.
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;
}
returned a much smaller error

firstC.c: In function `int main()':
firstC.c:9: error: parse error before `return'
The only difference is in the second pice of code, I dont have a semicolon at line nine at
 "\n"
at least its not that big mess of an error
But thanks again for all the help.
Mikey_Ickey is offline   Reply With Quote
Old Apr 28th, 2005, 11:06 PM   #19
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Old Apr 28th, 2005, 11:40 PM   #20
Mikey_Ickey
Newbie
 
Join Date: Mar 2005
Posts: 7
Rep Power: 0 Mikey_Ickey is on a distinguished road
yeah, i know but i do the whole spacing thing for readablilty.
Mikey_Ickey is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC