new to c+ need help =x

This is a discussion on new to c+ need help =x within the C++ Programming forums, part of the General Programming Boards category; ah ic thx =D...

  1. #16
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14
    ah ic thx =D

  2. #17
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    did you realy thought you needed more spaces? And did you actually considering counting how many spaces where there?

  3. #18
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14

    problem

    screenie
    Attached Images Attached Images  

  4. #19
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,522
    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.
    Code:
    // 01\01 Hello.cpp
    
    // end of text
    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 add
    Code:
    return 0;

  5. #20
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14
    i counted in between lol .. there were 6 spaces

  6. #21
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14
    lol thx citizen .. =D

  7. #22
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Whitespace is ignored in C++. You can do

    Code:
    #include <iostream>
    As much as you could do

    Code:
    #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.

    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:

    Code:
    //prints "Hello World!"
    std::cout << "Hello, World!";
    For longer amounts of documentation, use the old-school C comments:

    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;}

  8. #23
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14
    what is #include <iostream> and #include <ostream> explained in simple english?

  9. #24
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,522
    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.

  10. #25
    Registered User xdeathxc's Avatar
    Join Date
    May 2006
    Location
    SG
    Posts
    14
    btw i have to ask this. what is the recommended age to learn c++... i think im too young -.-

  11. #26
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by DougDbug
    I often compare programming with learning how to play a musical instrument... You can learn a few guitar chords in a couple of days, but you aren't going to impress anybody 'till you've been playing and practicing for about a year.
    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.

  12. #27
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,522
    btw i have to ask this. what is the recommended age to learn c++... i think im too young -.-
    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.

  13. #28
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    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.
    Code:
    if(a==b&&c!=5&&d<=7)
    if ((a == b)  &&  (c != 5)  &&  (d <= 7))
    These staements are the same to the compiler, but to the human the second one is more readable.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21