# I am interested in C/C++



## gopal (Sep 22, 2012)

Anyone know an good tutorial on it?
I really want to learn it, also what software i am gonna need to do that.

Reason for learning it:
PCSX2 is an emulator that emulates PS2 Games on PC i really like it and i wanna help them by doing something with C/C++.
I mostly intrusted in C/C++ because their software is mostly based on C/C++.

So i want to learn it!
I am looking for tutorials(if i can get Video tutorials then SUPERB), anyone know good tutorials?


----------



## Aquinus (Sep 22, 2012)

I would start with C and work your way to C++. I'm assuming you have enough underlying knowledge about how computers work at a low level to start learning C right off the bat.

Maybe something like this would help?

I'm not going to say that you can or can not learn how to program, writing code is the easy part. I think anyone can learn how to program but I'm not convinced that all people can program well or understand what other people have written.


----------



## gopal (Sep 22, 2012)

hmmm, C codes pretty much similar to .cns codes


----------



## Aquinus (Sep 22, 2012)

gopal said:


> similar to .cns codes



What's that?


----------



## gopal (Sep 22, 2012)

.cns is an component of M.U.G.E.N.
What is MUGEN?
Ans.- MUGEN is an game engine where you can customize EVERYTHING from Menus to stages to characters.
.cns is an file which an MUGEN character needed it contains every action of its.
An Example of how .cns looks

```
;---------------------------------------------------------------------------
; Stand
[Statedef 0]
type = S
physics = S
sprpriority = 0

[State 0, 1]
type = ChangeAnim
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < Const(movement.stand.friction.threshold)
trigger2 = Time = 4
x = 0

[State 0, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050
ctrl = 0

;---------------------------------------------------------------------------
; Stand to Crouch
[Statedef 10]
type    = C
physics = C
anim = 10

[State 10, 1]
type = VelMul
trigger1 = Time = 0
x = .75

[State 10, 2] ;Stop moving if low velocity
type = VelSet
trigger1 = abs(vel x) < Const(movement.crouch.friction.threshold)
x = 0

[State 10, 3]
type = ChangeState
trigger1 = AnimTime = 0
value = 11

;---------------------------------------------------------------------------
; Crouching
[Statedef 11]
type    = C
physics = C
anim = 11
sprpriority = 0

[State 11, 1] ;Change from turning animation
type = ChangeAnim
trigger1 = Anim = 6 && AnimTime = 0
value = 11

[State 11, 2] ;Stop moving if low velocity
type = VelSet
trigger1 = abs(vel x) < Const(movement.crouch.friction.threshold)
x = 0

;---------------------------------------------------------------------------
; Crouch to Stand
[Statedef 12]
type    = S
physics = S
anim = 12

[State 12, 1]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
```


----------



## Aquinus (Sep 22, 2012)

gopal said:


> .cns is an component of M.U.G.E.N.
> What is MUGEN?
> Ans.- MUGEN is an game engine where you can customize EVERYTHING from Menus to stages to characters.
> .cns is an file which an MUGEN character needed it contains every action of its.
> ...



Not quite. You have a lot more control of the system, the syntax is vastly different, variables are strongly typed, and you have memory pointers for accessing spots in memory dynamically. Also C doesn't work that way either, so other than both looking like some form of code (C is compiled and this most likely isn't as well,) I see no similarities with the example you provided.

Instead of trying to say it is like something (which it is very clearly not, sorry) I would just try to learn C and see how it goes.


----------



## gopal (Sep 22, 2012)

yeah, will try to learn it When i Translate(This) I am very busy so i can't do that now


----------



## rascal27 (Sep 24, 2012)

C and C++ is best thing to learn because all embedded codings are basically c...


----------



## Deleted member 3 (Sep 24, 2012)

You can't just learn some basic C and expect to be able to contribute to a complex project like PCSX2.


----------



## Aquinus (Sep 24, 2012)

DanTheBanjoman said:


> You can't just learn some basic C and expect to be able to contribute to a complex project like PCSX2.



+1: Correct! I'm willing to bet you the majority of those developers know more than just C, but how to develop, how to work in a team, and I'm willing to bet they have guidelines to code looks the same. If you really want to be able to work on complex projects like that you need a lot of experience and you need to start from the beginning.


----------



## Kreij (Sep 24, 2012)

DanTheBanjoman said:


> You can't just learn some basic C and expect to be able to contribute to a complex project like PCSX2.



Not to mention that you would need an intimate understanding of the hardware at it's lowest level  in order to write a software emulator for it, but hey !! A guy has to have goals !!


----------



## Frick (Sep 24, 2012)

I still think anyone even slightly interested in emulators should read this article:

Accuracy takes power: one man's 3GHz quest to build a perfect SNES emulator

It's kinda long but well worth it.


----------



## 3870x2 (Sep 24, 2012)

as others may have already pointed out, once you look at the big picture of what is actually required, you will feel very overwhelmed.  If you are just now learning, it will be a very long time before you will be able to contribute.  Learning c++ is barely scratching the surface.

Some may disagree, but c++ has made c obsolete, unless you are maintaining older code, or have specific reasons for it.  C is much closer to the ground level of machine language, and is very time consuming.


----------



## Frick (Sep 24, 2012)

3870x2 said:


> Some may disagree, but c++ has made c obsolete, unless you are maintaining older code, or have specific reasons for it.  C is much closer to the ground level of machine language, and is very time consuming.



I have some microcontrollers here that use C.


----------



## Aquinus (Sep 24, 2012)

Frick said:


> I have some microcontrollers here that use C.



A good reason to learn C. Being able to program embedded devices is a useful skill.


----------



## MxPhenom 216 (Sep 25, 2012)

Learn C#. Its basically the child of C and C++.


----------



## eidairaman1 (Sep 25, 2012)

it takes patience that's for sure especially when it comes to debugging million lines of code.

Read up on this stuff.

http://en.wikipedia.org/wiki/List_of_programming_languages

http://en.wikipedia.org/wiki/Low-level_programming_language

http://en.wikipedia.org/wiki/Assembly_language

http://en.wikipedia.org/wiki/Machine_code

http://en.wikipedia.org/wiki/Fortran

http://en.wikipedia.org/wiki/COBOL

http://en.wikipedia.org/wiki/BASIC

http://en.wikipedia.org/wiki/Pascal_programming_language

http://en.wikipedia.org/wiki/Esoteric_programming_languages

http://en.wikipedia.org/wiki/INTERCAL


----------



## GSquadron (Sep 25, 2012)

If you want to help them, study for 6 years and you are ready to help.
So if you are a true time waster learn c++ only to help them.


----------



## eidairaman1 (Sep 25, 2012)

Aye- Code Warrior Comes to mind (Talk about buggy in XP when I was in HighSchool 9+ Years ago)


----------



## Kreij (Sep 25, 2012)

MxPhenom 216 said:


> Learn C#. Its basically the child of C and C++.



If you are programming for hardware C# is not your best choice. You would have to circumvent a lot of the checks and balances that C# imposes, so you might as well just code in C or C++.

If you really want to dive into the hardware level, forget all the sissy intermediate and higher level languages and jump into assembly language.


----------



## Aquinus (Sep 25, 2012)

Kreij said:


> If you are programming for hardware C# is not your best choice. You would have to circumvent a lot of the checks and balances that C# imposes, so you might as well just code in C or C++.
> 
> If you really want to dive into the hardware level, forget all the sissy intermediate and higher level languages and jump into assembly language.



Yes! Then you start getting stuff that looks like this:


```
org     $2000
	lds     #$2000  ; Initialize the stack.
	ldaa    #16              ; just for testing, replace with buttons
	staa    cnt2            ; ditto

	ldaa	#0
	staa	strpt
	staa	incount
	
	jsr SETPASSWD

	jsr CHKPASSWD

lp1:	jsr GETKEY
	ldab KEY
	ldx incount
	stab str1,x
	inx
	stx incount
	jsr LCDOUT
	jmp lp1
	end
```

There is actually a lot more there, I just don't feel like cleaning up all the assembly to make it even slightly readable. 
Edit: This is also from an earlier save, so this example wouldn't actually be complete. It's an example of what you have to do though.

Like ldaa = Load Accumulator A (data register a)
staa = Store accumulator a
ldab = Store accumulator ab, which actually are data registers a and b to form 1 16-bit register instead of two 8-bit registers. (HCS12 can do both 8 and 16 bit math), but both memory address registers are 16-bit  (x and y) So...
stx = store x
ldx = load x

of course each of these has operands,
Each of these loads and stores take a memory address and as with any micro-controller or micro-processor, there are at least a couple different addressing modes.
then you have branching!

jsr = jump to subroutine
It jumps to the memory address in the first operand and it pushes the current IC (instruction counter register) to the stack and if the stack wasn't set to a spot in memory (lds) the processor will throw a fault code and halt.

...but with C, you don't have to worry about any of this, because the C compiler does it for you!


----------



## gopal (Sep 25, 2012)

this turned out difficult then i thought, maybe going to take about 5 yrs to learn


----------



## 3870x2 (Sep 25, 2012)

gopal said:


> this turned out difficult then i thought, maybe going to take about 5 yrs to learn



Collectively, this is what everyone is saying.

I would recommend learning it.  I get a great amount of joy and satisfaction, even if the project is trivial.


----------



## Aquinus (Sep 25, 2012)

3870x2 said:


> I would recommend learning it. I get a great amount of joy and satisfaction, even if the project is trivial.



+1: There is something to be said for creating something and making it work. I wouldn't do this for a living if I didn't feel this way.


----------



## TheMailMan78 (Sep 25, 2012)

I tried messing around with C+ a few months back with the encouragement of Kreij. I didn't even know what the terms meant to even start. I needed a day one schooling for this stuff. Not "How do you compile" but "What is it that am I compiling and what IS compiling". lol

Even the tutorials to me were like "WTF am I READING?!" Aerospace technology is WAY more simple then this stuff. 

Maybe I'm just to old to learn this kinda stuff. If your going for it at 13 years old gopal, don't let any of these people on a tech forum stop you. Learn it while you are young and stick with it through school. THEN go to school for it. Epic pay days can be had this way. I made a mistake long ago listening to people on career choices. IF I had stuck with what I enjoyed I would be working for Boeing or McDonnell Douglas right now.....like everyone else I went to school with lol.......but NOOOOOO I had to be different and pursue art.

EDIT: Also stay away from drugs and goth girls. Another mistake I made.


----------



## AphexDreamer (Sep 25, 2012)

You've just got to start programming as much as you can. 

Start thinking about how you can take real world problems and turn it into a program and try coding that, main thing being you want to code. 

Practice makes perfect.


----------



## librin.so.1 (Sep 25, 2012)

Every time someone refers to C and C++ as some singe entity, or worse - do so by using "C/C++" God kills a kitten.
...And someone programmer almost breaks his/her glasses due to a facapalming reflex.
Seriously, _Don't do it._ Please.
C and C++ are way too different to be refered as such.
Thank You.

Back on topic: If You do have the patience to learn C and/or C++, or better yet - master one or both, I'd say - go for it. Not only it will teach You programming, but also a lot of other skills that will probably be very useful overall. Even in things _not even related to computers_. Not to mention it greatly develops logical thinking and discipline. A tripple Win!


----------



## Peter1986C (Sep 26, 2012)

^^ Even I (someone with no more programming experience than some basics in Pascal/Delphi, a long time ago) understand that C and C++ are different. C is differently oriented while also being of a lower level than C++ (am I right about that?).


----------



## eidairaman1 (Sep 26, 2012)

Chevalr1c said:


> ^^ Even I (someone with no more programming experience than some basics in Pascal/Delphi, a long time ago) understand that C and C++ are different. C is differently oriented while also being of a lower level than C++ (am I right about that?).



C++ is originally an Evolution of C.


----------



## eidairaman1 (Sep 26, 2012)

It takes patience for this kind of programming language.

Staying away from Drugs? Yes

Staying away from Gothic Women? No- have as much fun as you can



TheMailMan78 said:


> I tried messing around with C+ a few months back with the encouragement of Kreij. I didn't even know what the terms meant to even start. I needed a day one schooling for this stuff. Not "How do you compile" but "What is it that am I compiling and what IS compiling". lol
> 
> Even the tutorials to me were like "WTF am I READING?!" Aerospace technology is WAY more simple then this stuff.
> 
> ...


----------



## GSquadron (Sep 26, 2012)

Why goth girls?
What about girls? (without any type like goth)


----------



## Jimmy6 (Dec 11, 2013)

You got the right idea there and the thinking now just write the source code and compile it. You won't learn anything if someone does it for you. If you really need it perhaps there's source code for the same idea online for download.


----------



## OnePostWonder (Dec 11, 2013)

Jimmy6 said:


> You got the right idea there and the thinking now just write the source code and compile it. You won't learn anything if someone does it for you. If you really need it perhaps there's source code for the same idea online for download.



I'm just gonna throw this out there.

You do realize you're suggesting someone do something they were trying to do over a year ago.


----------



## Blue-Knight (Dec 11, 2013)

I wouldn't recommend C/C++ to anyone. But "*Yes, you can*" learn it.

It all depends on your will to learn and/or dedication.


----------



## BiggieShady (Dec 11, 2013)

This is how to learn C++ in 21 days:





... but seriously, just get to day 697 and you'll be good enough to contribute.


----------



## Blue-Knight (Feb 7, 2014)

johnstyle said:


> It is the best language for beginner who want to start learning programming. C language is easy to learn and understand.


I disagree. In my opinion, every beginner should start with the lower level language possible (e.g.: Assembly, using an assembler and not programming bit by bit).

Why? High level programming languages are too "complex" and hides the fundamental basics of how a program really works. And even complicates simple things (often)...

Why? I started with a high level programming language and after I met Assembly, I wished I could start with it because I really learned how the things work with it. And after I met Assembly I could understand and learn higher level languages a LOT better and easier.

That's my opinion!


----------



## Frick (Feb 7, 2014)

Blue-Knight said:


> I disagree. In my opinion, every beginner should start with the lower level language possible (e.g.: Assembly, using an assembler and not programming bit by bit).
> 
> Why? High level programming languages are too "complex" and hides the fundamental basics of how a program really works. And even complicates simple things (often)...
> 
> ...



C is pretty low to begin with. Assembly is probably fine, but these days I think it's a bit too abstract (if by abstract you mean hard to understand). You obviously need it sometimes, but if you just want to program as a hobby and dabble with electronics C is pretty good I think.


----------



## Blue-Knight (Feb 7, 2014)

Frick said:


> C is pretty low to begin with.


Compared to raw Assembly it is pretty high, especially pointers and arrays (for example).

Not to mention the "if, else, and, or" and other operators that make multiple/complex comparisons much faster than if coded in raw Assembly.


----------



## MustSeeMelons (Feb 7, 2014)

I started programming in Pascal, then went to C, then to C++, then Java. Pascal was good to learn the core basics, although it's more or less useless practically. I'd say, don't start low-level, rather go high and then down.  To be honest, Java could be a good starting point, it can be very high level, but you can easily get the basics out and when you are ready, go down to C++ to really understand what that 'new' operator is, what's a memory leak etc. Low level can be a bot too broad to grasp, but that's just me


----------



## Blue-Knight (Feb 7, 2014)

MustSeeMelons said:


> Pascal was good to learn the core basics, although it's more or less useless practically.


You must be kidding or you do not know Pascal enough. The "Free Pascal Compiler" is simply great and very complex/advanced.

As a "Free Pascal" user I can say it is a VERY POWERFUL compiler and you won't feel the absence of C or other high level languages with it (as I did). Anyway, for other specific things that can't be done in Pascal (or any other high level language), Assembly is there for you.

But for general programming, it is much more than enough.


----------



## MustSeeMelons (Feb 7, 2014)

The thing with Pascal is that - it's _old_. (Is there a user friendly IDE?) True, I've almost completely forgotten Pascal - Java is my daily driver and C++ is my tinkering language.


----------



## Blue-Knight (Feb 7, 2014)

MustSeeMelons said:


> The thing with Pascal is that - it's old.


C is old, many other languages are old.

The thing is: Some of them are old but they are still in constant and active development, they continue to improve each year and support newer architectures/technologies and being old and under constant development is a very good thing actually. If they were old and development was abandoned they would be considered obsolete already (which didn't happen).


----------



## Wrigleyvillain (Feb 7, 2014)

Check out edX and Coursera. Free actual college courses from the institutions themselves and an excellent structured environment in which to give it a real shot. And if you can't keep up you will at least now know what you need to concentrate more on. For me it's math when it comes to things like this (tried Python).


----------



## Aquinus (Feb 7, 2014)

I feel the opposite. Most modern high-level languages will handle a lot of things for you. Not that doing a little bit of assembly didn't help me, but I wouldn't say it helped me with much development I did down the road. You can bash it, but Java isn't a bad a place to start. If you're thinking scripting languages, python and ruby aren't bad. You should learn a language that is good at doing whatever you want to be doing. If you're going to be writing drivers or anything that runs at the OS/driver level, then maybe assembly will help understand how you can save a few clock cycles by doing things a particular way in C.

I've been using Clojure recently and I've been enjoying it a lot because it does just about everything I want it to do very well. Granted, it's not you're typical procedural programming language. It is a dialect of LISP, so be prepared to change how you think about data.


----------



## BiggieShady (Feb 7, 2014)

Frick said:


> C is pretty low to begin with.





Blue-Knight said:


> Compared to raw Assembly it is pretty high, especially pointers and arrays (for example). Not to mention the "if, else, and, or" and other operators that make multiple/complex comparisons much faster than if coded in raw Assembly.



Frick is right on this one. Compared to assembly, it is not much higher. 
Pointers in C simply cannot be different than pointers in assembly, because pointer is a address of a variable and assembly works directly with memory addresses and registers (variables in asm are symbolic). Arrays work the same as in c (offset to memory address of first element) only c has operator [ ]. 
Flow control instructions (if,else) are not operators. Boolean expressions used within flow control instructions use boolean operators (and, or, ...). 
Coding in raw assembly is done by directly embedding asm code in c code and it is done only for some parts of critical sections where compiler cannot be instructed with a flag how to behave properly.


----------



## Blue-Knight (Feb 7, 2014)

BiggieShady said:


> Pointers in C simply cannot be different than pointers in assembly, because pointer is a address of a variable and assembly works directly with memory addresses and registers


I was telling the way it is accessed in code, which is pretty different. And yes, compared to raw assembly it is pretty high level (a fact).

And construction of complex/multiple/nested comparisons in C or other high level language can be done in seconds while in raw assembly will cost you minutes to hours, depending on complexity. And other thing is about data structures, high level languages such as C make access and organization a lot faster.

This is not even close to assembly level, please.


----------



## BiggieShady (Feb 7, 2014)

Blue-Knight said:


> I was telling the way it is accessed in code, which is pretty different. And yes, compared to raw assembly it is pretty high level (a fact).
> 
> And construction of complex/multiple/nested comparisons in C or other high level language can be done in seconds while in raw assembly will cost you minutes to hours, depending on complexity. And other thing is about data structures, high level languages such as C make access and organization a lot faster.
> 
> This is not even close to assembly level, please.



Of course C is a high level language ... is it as low as you can go with high level languages? Yes.

Does anyone write comparisons in asm? No. Data stucturs in asm? No, they use C. Asm get embeded in c code for some parts of a critical section. Just as I already said.

My point? Compilers are so great that you don't magically gain speed simply by doing everything in raw assembler, optimizing using powers of a human brain.

EDIT:

Actually I misread this


Blue-Knight said:


> ... make multiple/complex comparisons much faster than if coded in raw Assembly.


as this


Blue-Knight said:


> ... make multiple/complex comparisons much faster when coded in raw Assembly.


so we are kind of making a same point


----------



## Blue-Knight (Feb 7, 2014)

BiggieShady said:


> Does anyone write comparisons in asm?





BiggieShady said:


> Data stucturs in asm?


Yes, me! Not while using a high level language but when coding a program or specific function in assembly (using an assembler).

As I do not work professionally in this field I can choose any tool/language that I need/want. And that's what makes me happy! 

Of course, coding an entire program in Assembly for competition is out of question nowadays... Not impossible, but you know time is money.

Happy New Year!


----------



## BiggieShady (Feb 7, 2014)

Blue-Knight said:


> Happy New Year!



lulz, happy new year to you too



Blue-Knight said:


> Of course, coding an entire program in Assembly for competition is out of question nowadays... Not impossible, but you know time is money.



Imagine what would it be like ... managing call stack manually and saving registers every time you call a function ... I'd go insane ... I mean more insane


----------



## Aquinus (Feb 7, 2014)

BiggieShady said:


> lulz, happy new year to you too
> 
> 
> 
> Imagine what would it be like ... managing call stack manually and saving registers every time you call a function ... I'd go insane ... I mean more insane



A number of CPUs have instructions that handle pushing the state of the registers to the stack and popping them off when you call and return from a sub-routine. When you start writing the application you need to define where in memory the stack begins, but beyond that, the CPU handles a number of things like that at the hardware level. It depends on the architecture though. A good example is if the stack pointer isn't in the same place when you return from the sub-routine as when you started it, you'll be in trouble, also if you alter deeper contents of the stack.


----------



## punisher186 (Feb 21, 2014)

BiggieShady said:


> Imagine what would it be like ... managing call stack manually and saving registers every time you call a function ... I'd go insane ... I mean more insane



Have you played Cruis'n USA?  250,000 LOC of raw assembly.  No 3d libraries, no engine, no OS, just raw code.


----------



## BiggieShady (Feb 21, 2014)

punisher186 said:


> Have you played Cruis'n USA?  250,000 LOC of raw assembly.  No 3d libraries, no engine, no OS, just raw code.



Never played it on a console (I did once in arcade), have been pc gamer since '94 ... it reminds me of 'Lotus The Ultimate Challenge' I've played back in the days on ms-dos


----------



## Scrizz (Feb 23, 2014)

If someone reads this now, I'd suggest learning programming logic before learning a language. 
or at least learn logic with a language lol.


----------



## de.das.dude (Feb 23, 2014)

i know you and i feel you should focus more on school now. youre like 12years old. you will soon be taught c++ in school if you take up computer science later in 10+2.


----------



## OnePostWonder (Feb 23, 2014)

de.das.dude said:


> i know you and i feel you should focus more on school now. youre like 12years old. you will soon be taught c++ in school if you take up computer science later in 10+2.



Imagine my confusion.  You know who, gopal?  If you know him in real life, you could probably tell him more there, but he made this thread 1.5 years ago.


----------



## de.das.dude (Feb 24, 2014)

OnePostWonder said:


> Imagine my confusion.  You know who, gopal?  If you know him in real life, you could probably tell him more there, but he made this thread 1.5 years ago.


yes lol. he is in my neighboring state.


----------



## OnePostWonder (Feb 24, 2014)

de.das.dude said:


> yes lol. he is in my neighboring state.



Lol, okay.  I didn't know how well you know him - I think sometimes people might see each other every day, but still communicate things through the internet they could the next time they see the  person.


----------

