Jump to content
xisto Community
Sign in to follow this  
zamaliphe

Learn C/c++ From The Beginning C/c++ tutorials for beginners and expert at the same time

Recommended Posts

Hello every one
Today Im going to write good c c++ tutorials
The tutorials are mine showing my experience in c c++
i my be using some examples rote in some books (if i do i will pot a link or name of the book)
And all the tutorials are at the main topic
I dont know how my topic count in this case because all Im going to do is updates the same topic
Any way lets just tray and see
First sings first in order to compile your code you need compiler
That compiler is an application that converts your code from human readable code to
Binary cod or machine code
There is allot of compilers out their
(I will post some links soon)
The first code you might wan do is simple
And do some actual work
Lets start with the oldest and greatest and simplest code
Hello world

You can get that code from almost any compiler as a simple project

// hello world.cpp : Defines the entry point for the console application.//#include <stdio.h>int main(int argc, char* argv[]){	printf("Hello World!\n");	return 0;}

Now what is that code
Lets explain
Line after line

1-#include <stdio.h>
You tell see that you want to use the input output library
In English you can use the keyboard to input and the
Screen to output
Thats all
2-int main(int argc, char* argv[])
This is the main function
You cant compile your code without this function
I will explain it later
3-printf ("Hello World!\n");


[To be continuing ]

Share this post


Link to post
Share on other sites

Actually, #include tells that you want to include a header file that contains code.#include "hi.h" would mean that you want to include hi.h from the directory that the file containing that code is in.int argc, char* argv[] isn't really required as parameters for int main() unless you want arguments to be passed from the command lineAnd overall, printf is mainly a C function. C++ has a better way of outputting.

Share this post


Link to post
Share on other sites

Actually, #include tells that you want to include a header file that contains code.#include "hi.h" would mean that you want to include hi.h from the directory that the file containing that code is in.
int argc, char* argv[] isn't really required as parameters for int main() unless you want arguments to be passed from the command line

And overall, printf is mainly a C function. C++ has a better way of outputting.

thanks for reblay i will edit the post
and i know that c++ use "cout" for outpot
and i useed the argc, char* argv[] because i will write som examples about them later
i meant the full line
#include <stdio.h>
not just #include
that tels the compiler that i need to use the input output function in c
that means the code for this functions is in the file "stdio.h"
once moor thanks and fell free to fix any error
in my topic

Share this post


Link to post
Share on other sites

#include<stdio.h> means to include a header file named standard input/output, whose function is explained by Zamaliphe above.And main function is the first function from where execution starts.Zamaliphe, a suggestion to you. You should give/explain whole thing (all functions used by you) at one post itself, no problem the length of the posts increases. Because it gives beginners to learn and people like us to comment on it. In this program, if your motto was only to teach printf function, then there was no need to use the arguments. Also if where planning to show something else with those (as you have said) then you should explain it in one post itself.

Share this post


Link to post
Share on other sites

Hi im a pc programmer and a game programmer i use Dev - c++ your tutorials arent bad but can you please state what application you are using??
Thanks

Painbringer

OK in windows i use Dev - c++ also
some times i use Microsoft Visual C++ 6.0 and MSDN library
and on Linux i like the old fashion compiler
gcc
on the command line
most of times i create and script to automate the compiling process
using make or even just bash script
and i like c on Linux moor than windows



#include<stdio.h> means to include a header file named standard input/output, whose function is explained by Zamaliphe above.And main function is the first function from where execution starts.

Zamaliphe, a suggestion to you. You should give/explain whole thing (all functions used by you) at one post itself, no problem the length of the posts increases. Because it gives beginners to learn and people like us to comment on it. In this program, if your motto was only to teach printf function, then there was no need to use the arguments. Also if where planning to show something else with those (as you have said) then you should explain it in one post itself.

thanks for your suggestion I'm working on it

by the way I'm too lazy
so it might take few dye's to complete that tutorials

and this is not teach print function only

this is just start

and every one start learning programming

like to see what he dos on the screen

so teach printf function

is the most important sing for beginners

thanks for the comment and i have not start even yet
Edited by zamaliphe (see edit history)

Share this post


Link to post
Share on other sites

Hello, i'm a new user in programming and i'm more interested in web interaction ones. My question is: is c/c++ a good program for web interaction? Is there an easier way to create a gui?What i want to do is a mysql interaction, consult and confirmation, and include that on vb. is it possible?

Share this post


Link to post
Share on other sites

wouldn't a "cout" be easier?with visual C++ 6.0

#include<iostream.h>int main(){cout << "Hello World" << endl;}

iostream = input output streamendl = endline

Share this post


Link to post
Share on other sites

@zamaliphe: I believe there *still* is a tutorial section of this site, why not just post this stuff there?Not everyone here is a n00b or needs to see yet another tutorial, and there's a clearly definedforum feature for it.About your code - you gave a PURE C program - for crying out loud, you gave arguments to main(),so what's with the the association with C++?@Csshih: That's technically bad code is why. You didn't declare a namespace for cout.It's a lot easier to write printf() than std::cout any day just because you don't have tostand there all day shifting to get a colon.Logically speaking, it'd still be easier to do a printf() because there's no classes toabstract around.@de4thproof: C/C++ is not the easiest language to perform web interaction in.My recommendation would be perl, but assuming you're doing things with a basis of client-serverrelationships, PHP would do really nicely too.-And a general question for everybody... why're we treating C and C++ as the same thing?They're not, they're just very well associated with each other.

Share this post


Link to post
Share on other sites

Sure, no problem. In your code, you posted "cout <<" something without declaring the std (standard) namespace. Basically, you referred to something that doesn't exist all by itself in the C++ language, but rather in a standard group of functions. std - the namespace - is defined in iostream, cout is defined as part of std. So for a program, people would normally write std::cout. Now, if you wanted to write just cout, you would write "using std" before going "cout" something to tell the compiler that if something's not in the list of definitions, look in the std namespace.

 

Normally, just posting "cout" something is fine because some compilers use std as default , but at least a few ANSI-strict compilers will have problems with that - and a lot of older compilers will have problems with that too. Also, supposing that you made another namespace - say foo for example - and you declared using foo before you declared "cout". Then instead of referring to std::cout, you'd be referring to foo:cout, which is probably not what you want. ~ It's just bad for portability and some style reasons.

 

Tell me if that makes sense.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.