954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Do i need C to learn C++?

Hi, im new to programming. I have read alot of posts on this site and am wondering if i need to learn C before i learn C++. Is learning a language before C essential? or will i just get the hang of it.
This is my second post, asking about what to learn, i am just getting confused with what and which to learn first.
I have been told to start with VB, or just start with C, and have even read that i can just learn C++ straight away. ?!

Thanks

PS. you got any good sites for free books or tutorials?

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

You do not need to learn c before c++.

I found c++ so easy to learn, it should be like a walk in the park.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

it is much easyer to understand c++ if you know c....

C++ isnt difficult...some people think (like me) that c++ is easyer to learn than c

jan1024188
Posting Whiz in Training
254 posts since Aug 2006
Reputation Points: 27
Solved Threads: 2
 

K, cool. Was it the first language you learnt?

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

>it is much easyer to understand c++ if you know c....

Perhaps, but some people still think c++ is just c with classes.

My advice would be to learn c++ on its own away from the distractions of c.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Sweet, thnx. You guys reply sooo fast :D:D:D

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 
K, cool. Was it the first language you learnt?


my first language was pascal..

jan1024188
Posting Whiz in Training
254 posts since Aug 2006
Reputation Points: 27
Solved Threads: 2
 

Thnx for replies guys :D very helpful
i found a different thread that was also very helpful :D http://www.daniweb.com/techtalkforums/thread52366.html
I am currently reading http://cplusplus.com/doc/language/tutorial/
I am just starting out, i hope i will pick up quite ^^

TY again
Love from The WoBinator

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

omg...last question ^^

ive written and comiled the "hello world" thing using Dev-C++

when i run the exe, a dos-like window pops up for half sec and dissapears...wtf? ive read and reread over what i am meant to do...?!?!?! is that whats meant to hpn?

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

omg...last question ^^

ive written and comiled the "hello world" thing using Dev-C++

when i run the exe, a dos-like window pops up for half sec and dissapears...wtf? ive read and reread over what i am meant to do...?!?!?! is that whats meant to hpn?

Thats because when "Hello word" is printed on a screen program ends and cmd clooses...

jan1024188
Posting Whiz in Training
254 posts since Aug 2006
Reputation Points: 27
Solved Threads: 2
 

also you can get free c++ videotutorials here
http://seangreasley.com/

jan1024188
Posting Whiz in Training
254 posts since Aug 2006
Reputation Points: 27
Solved Threads: 2
 
also you can get free c++ videotutorials here http://seangreasley.com/


awwww sweet as! thnx man!

WoBinator
Newbie Poster
22 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 
omg...last question ^^ ive written and comiled the "hello world" thing using Dev-C++ when i run the exe, a dos-like window pops up for half sec and dissapears...wtf? ive read and reread over what i am meant to do...?!?!?! is that whats meant to hpn?



Add

system("PAUSE");

in front of return 0;

Boldgamer
Light Poster
44 posts since Dec 2006
Reputation Points: 11
Solved Threads: 2
 

ive written and comiled the "hello world" thing using Dev-C++

when i run the exe, a dos-like window pops up for half sec and dissapears...wtf? ive read and reread over what i am meant to do...?!?!?! is that whats meant to hpn?


The program is doing exactly what it is supposed to do, the only thing being the command window closes after displaying the output.

To make the command window stay, make the program wait for some event (like accepting a key from the user) to see the expected output.

In C dogetchar( ) at the end of the program.
In C++ do cin.get( ) at the end of the program.

Any other method used, is totally platform / compiler dependent and should be best avoided.

BTW even system( "pause" ) is a non-standard method which is best avoided.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

For a standard, safe way of getting the program to pause, you could use a function like this

#include <iostream>
#include <limits>

void stop()
{ 
    std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
    std::cin.get();
}

int main()
{
    stop();
}
Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

For a standard, safe way of getting the program to pause, you could use a function like this

#include <iostream>
#include <limits>

void stop()
{ 
    std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
    std::cin.get();
}

int main()
{
    stop();
}

wow but this doesnt make sense

why dont you just type

#include <iostrem.h>

using namespace std;


void main()
 {
cout << "\n" ;
cin.get();
return(0);
}
jan1024188
Posting Whiz in Training
254 posts since Aug 2006
Reputation Points: 27
Solved Threads: 2
 

@ Bench
Just to let you know that the functions cin.ignore( ) and cin.get( ) won't function as expected if the standard input stream is corrupted and its status bit not cleared. Your code is good and robust but to make it to adapt to stream corruptions, do something like:

#include <iostream>
#include <limits>

void stop( )
{
    using namespace std ;

    cin.clear( ) ;
    cin.ignore( numeric_limits<streamsize>::max(), '\n' ) ;
    cin.get( ) ;
}


@jan1024188
There are some cases in which the simple statement getchar( ) or cin.get( ) won't work. Those being corrupted stream, or more than a single newline character hanging in the stream.

For simple cases the primitive statements work well, but if your program is a highly CUI (console user interface) dependent, you might want to have a robust function like mentioned above by me and Mr. Bench to handle fatalitites ;).

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

I wouldn't put 'using namespace std' within the scope of a function.

It is better to state it at the top - just under the headers.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
#include <iostrem.h>

using namespace std;


void main()
 {
cout << "\n" ;
cin.get();
return(0);
}


We've told you time and time again, don't use void main and don't use iostream.h.

But what do you do? Dearie me.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

I wouldn't put 'using namespace std' within the scope of a function.

It is better to state it at the top - just under the headers.


Declarations are best made in the proximity where they are required to be used. Limiting the scope of the namespace declaration namespace collisions can be avoided.

Programs should be made avail of only that much functionality which concerns them hence declaring the namespace in the function was for the best.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You