ah ic thx =D
did you realy thought you needed more spaces? And did you actually considering counting how many spaces where there?
There are a few lines in your program that do not need to be there. If you really want to keep them there, use a comment.Also note that main returns an int at the end, a zero to indicate success. If the program crashes main will return some random number for an int instead, so that Windows can tell you a program crashed. At any rate you need to addCode:// 01\01 Hello.cpp // end of textCode:return 0;
i counted in between lol .. there were 6 spaces
Whitespace is ignored in C++. You can do
As much as you could doCode:#include <iostream>
Both will compile to the same bits of code. Whitespace is generally used to visually structure code to make it easier to read.Code:#include <iostream>
Note that any text in the code will be compiled. Thus, as the compiler has no idea what you mean by "end of text", an error is generated. If you want to keep it in the source file as documentation, use commenting:
For longer amounts of documentation, use the old-school C comments:Code://prints "Hello World!" std::cout << "Hello, World!";
Code://start of comment is "/*", end is "*/" /* int Krypton() This will return an unsigned handle identifier to the bloody egg-white mass of Krypton Intended to be used to combat Superman's meternal mortal enemies and reestablish intergalactic peace in main(). Some more random text here... */
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
what is #include <iostream> and #include <ostream> explained in simple english?
Besides that you don't need to include both of them like that; without going into exaustive detail, iostream provides the classes that you use to print output to the screen, get input from the keyboard, and log and print I/O errors. Check an online reference for more.
btw i have to ask this. what is the recommended age to learn c++... i think im too young -.-
To add to your example. After a year, you can impress musically challenged people but you look musically challenged to real musicians. There's always someone better, or at least, someone to learn from.Originally Posted by DougDbug
Hmm... well, most people start in high school, I think. However, just because that is the usual cause doesn't mean that you can't start now. It might be harder though, programming needs discipline and an appetite for learning and solving problems.btw i have to ask this. what is the recommended age to learn c++... i think im too young -.-
You are only too young if you think you are. Age usually doesn't matter. Although a 3-year-old probably wouldn't have the attention span to learn programming...
As for SPACE vs TAB, use SPACEs. Liberally.
These staements are the same to the compiler, but to the human the second one is more readable.Code:if(a==b&&c!=5&&d<=7) if ((a == b) && (c != 5) && (d <= 7))
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers