stupid program question

This is a discussion on stupid program question within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Hugo716 hmm wots EOF? How about "wots FAQ "? As in, FAQ > Explanations of... > Definition ...

  1. #16
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by Hugo716
    hmm wots EOF?
    How about "wots FAQ"? As in,
    FAQ > Explanations of... > Definition of EOF and how to use it effectively
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  2. #17
    Registered User
    Join Date
    Apr 2006
    Posts
    132
    hehe, thanks

  3. #18
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    EOF means end of file

    putting a semi-colon after the main function is just asking for trouble.
    Look at this...

    Code:
    #include <iostream>
    
    using std::cout;
    using std::endl;
    
    // function prototypes
    void func ( void );
    void funct2 ( void );  // it is ok to end function prototypes with a semi=colon
    
    int main ( void );  // this is an error
    {
    func(); // function calls end with a semi-colon
    
    return 0;
    
    cin.get();
    }
    
    void func ( void ); // this is an error
    {
    func2();
    }
    
    void func2 ( void ); // so is this
    {
    }
    in general. NEVER place a semicolon after function title implementation.
    ONLY include a semi-colon after a function prototype and when you call a function

    Hope this helps -pete

  4. #19
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    You'll need to understand the difference between a function DECLARATION and a function DEFINITION. A declaration simply asserts that a function exists and is ready for use.

    Code:
    int main(int, char**);
    So you can use main() although you haven't defined it's contents (although calling main() is a VERY BAD IDEA™). But to really compile your code, you'll need to define what main() does. This is the definition, which does not include the semicolon to differentiate it from a declaration:

    Code:
    int main(int n, char **v)
    {
        std::cout << "Hello World!\n";
        std::cin.get();
    }
    Last edited by jafet; 05-26-2006 at 10:23 PM.
    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;}

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

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 05:43 AM
  2. question about the loop in case conversion program
    By Elhaz in forum C++ Programming
    Replies: 8
    Last Post: 09-20-2004, 05:06 PM
  3. program design question
    By theroguechemist in forum C++ Programming
    Replies: 4
    Last Post: 03-02-2004, 08:45 PM
  4. Stupid Question.........
    By incognito in forum Windows Programming
    Replies: 6
    Last Post: 04-06-2002, 09:59 PM
  5. Question about "Answer Key" Program
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 11-14-2001, 09:55 PM

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