|
|
|
|
![]() ![]() |
Nov 17 2007, 12:44 AM
Post
#1
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 131 Joined: 1-February 07 Member No.: 38,108 |
Hello every one
Today I’m 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 don’t know how my topic count in this case because all I’m 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 Let’s start with the oldest and greatest and simplest code Hello world You can get that code from almost any compiler as a simple project CODE // 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 Let’s 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 That’s 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 ……] |
|
|
|
Nov 17 2007, 03:11 AM
Post
#2
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 85 Joined: 27-December 04 Member No.: 2,976 |
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. |
|
|
|
Nov 17 2007, 04:05 AM
Post
#3
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 131 Joined: 1-February 07 Member No.: 38,108 |
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 |
|
|
|
Nov 17 2007, 01:02 PM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 537 Joined: 21-August 06 From: Ziya's Heart Member No.: 28,693 |
#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. |
|
|
|
Nov 17 2007, 01:49 PM
Post
#5
|
|
|
Newbie ![]() Group: Members Posts: 2 Joined: 17-November 07 Member No.: 53,218 |
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 |
|
|
|
Nov 18 2007, 12:44 AM
Post
#6
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 131 Joined: 1-February 07 Member No.: 38,108 |
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 This post has been edited by zamaliphe: Nov 18 2007, 12:56 AM |
|
|
|
Nov 24 2007, 04:24 AM
Post
#7
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 76 Joined: 21-November 07 Member No.: 53,412 |
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? |
|
|
|
Dec 3 2007, 05:14 PM
Post
#8
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 190 Joined: 20-April 06 From: from the Dumpster in the back Member No.: 22,158 |
wouldn't a "cout" be easier?
with visual C++ 6.0 CODE #include<iostream.h> int main() { cout << "Hello World" << endl; } iostream = input output stream endl = endline |
|
|
|
Dec 5 2007, 12:57 AM
Post
#9
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 397 Joined: 14-November 04 From: Elysium Member No.: 2,280 |
@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 defined forum 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 to stand there all day shifting to get a colon. Logically speaking, it'd still be easier to d |