Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 From C++ to C
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mazer




PostPosted: Wed Sep 08, 2004 3:58 pm   Post subject: From C++ to C

I'm starting computer science in University tomorrow, and for some reason we're going to be doing C. Stupid prof. He/she wrote the textbook that we're using, so it seems to me that there's a bit of an ego problem here. I've never actually used C before but some of the things I've heard is that there are no classes, and the structs only let you have member variables (no functions). What are the advantages of C? What else do I need to know?
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Wed Sep 08, 2004 4:05 pm   Post subject: (No subject)

well c++ is a superset of c, so you lose a bunch of nice features (such as classes, templates, new and delete, among others). But you supposedly gain a small speed increase. The reason they probably start with c is to avoid diving into oop right away
Mazer




PostPosted: Wed Sep 08, 2004 4:18 pm   Post subject: (No subject)

I figured as much. Which is just dumb. OOP is easier. So I no longer get to use new or delete... what is it now malloc() and free() or something? Bleh. At least it's not turing?
rizzix




PostPosted: Wed Sep 08, 2004 5:51 pm   Post subject: (No subject)

yea well look at it this way.. it has been tested that c++ is much slower than C. thats why c++ is never used for creating realtime OS's or programs.. u know stuff used in robots/spacecrafts// etc... wherever performance is crucial. it is important u know C.. some stuff is a little different for the normal C++ way of doing things.

PS: after learning C, objective-c is a piece of cake.. u should take a look at it.

PSS: i dont really see a diff in performance in C++ and C.. but statistically there supposed to be Confused
wtd




PostPosted: Wed Sep 08, 2004 7:03 pm   Post subject: (No subject)

C as a language is actually much better suited to teaching than C++. C++ features a byzantine syntax with a lot of rules, and even more exceptions to those rules. C is much simpler.

This doesn't mean that C is necessarily a better language, but it makes it easier to learn.

A quick translation:

code:
// C++

#include <iostream>

int main()
{
   std::cout << "Hello, C++" << std::endl;
}


code:
/* C */

#include <stdio.h>

int main()
{
   puts("Hello, C");
}
Acid




PostPosted: Thu Sep 09, 2004 1:38 pm   Post subject: (No subject)

I remember hearing a quote that went something like, "Programming with C makes it easy to shoot yourself in the foot. In C++ it's harder, but when you do you take the whole leg."
Andy




PostPosted: Thu Sep 09, 2004 3:15 pm   Post subject: (No subject)

and that is relevant to his question how?
rizzix




PostPosted: Thu Sep 09, 2004 4:48 pm   Post subject: (No subject)

well you dont want to C a shot foot.. even worse is Cing plus plus the rest of your body damaged.
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Sep 09, 2004 6:04 pm   Post subject: (No subject)

LOL nice... very nice rizzix
Acid




PostPosted: Fri Sep 10, 2004 1:05 pm   Post subject: (No subject)

dodge_tomahawk wrote:
and that is relevant to his question how?


I was just saying. It wasn't supposed to be relevant to the question.
bugzpodder




PostPosted: Fri Sep 10, 2004 3:22 pm   Post subject: (No subject)

personally i am having a lot of trouble with that also (dont ask me why i want to write my programs in C)

some of this are compiler dependant

first of all, this wont work: int f(int &a, int &b)
secondly this also wont work

.....//some code
int a;

as intializations must be placed on the top

and one more problems, it doesnt like // comments. i think /* works */

as well as a lot of other things i dont know
Andy




PostPosted: Fri Sep 10, 2004 4:30 pm   Post subject: (No subject)

so what are you supposed to do in the case of int f(int &a, int &b)?
Catalyst




PostPosted: Fri Sep 10, 2004 4:31 pm   Post subject: (No subject)

use pointers probably
Andy




PostPosted: Fri Sep 10, 2004 4:35 pm   Post subject: (No subject)

argg..... not that i dun like pointers, im just lazy
bugzpodder




PostPosted: Fri Sep 10, 2004 4:47 pm   Post subject: (No subject)

Catalyst wrote:
use pointers probably


yes, something like int f(int *a, int *b){ *a^=*b^=*a^=*b;} //doesnt work if a=b
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: