Results 1 to 6 of 6

Thread: alittle code help

                  
   
  1. #1

    Default alittle code help

    well i was following this tut and did it the exact same way but its not compiling



    PHP Code:
    #include <iostream>

    using namespace std;

    void printString(void);
      
    void simpleFunc (void);

    void main()

    {
        
    cout <<"Before Function Call"<<endl;
        
            
    printString();
        
            
    cout <<"After Function Call"<<endl;

    }

            
    void simpleFunc (void);

    {
        
    cout <<"We are inside simple func"<<endl;
    }

           
    void printString(void)

    {
        
    cout <<"In Function Call"<<endl;
        
            
    cout<<"Hello World"<<endl;

        
    simpleFunc();

    PHP Code:
    error
    c
    :\documents and settings\pc\desktop\p2vid\functions2\functions2\fun2.cpp(14) : errorC2447'{' missing function header (old-style formal list?) 
    thanks for the help

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    Change:

    void simpleFunc (void);
    {
    cout <<"We are inside simple func"<<endl;
    }

    to

    void simpleFunc (void)
    {
    cout <<"We are inside simple func"<<endl;
    }

  3. #3

    Default

    Quote Originally Posted by yaustar View Post
    Change:

    void simpleFunc (void);
    {
    cout <<"We are inside simple func"<<endl;
    }

    to

    void simpleFunc (void)
    {
    cout <<"We are inside simple func"<<endl;
    }
    Thanks so much just would like to know what is the difference between the 2 of them

  4. #4

    Default

    i have the same problem with this one here

    PHP Code:
    #include <iostream>
    using namespace std;

    void printString(char *str);
    int stringlength(char *str);

    void main()
    {
        

        
    int strlen stringlength ("Dan");
        
    cout<< strlen<<endl;
    }

    int stringlength(char *str);

    {
        
    int length =0;
        while (
    str[length] != '/0')/*!=doesnt= to know character 0*/
        
    lenght++;/*movin to next char in string*/

        
    return length;
    }


    void printString(char *str)
    {
        
        
    cout<<"Hello"<< str <<endl;


  5. #5

    Default

    You need to remove the ; at the end of

    int stringlength(char *str);

    so it becomes

    int stringlength(char *str)

    (Not from the top declaration part, but from the actual function in the middle if your code)

    --DeNitro

  6. #6
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    void simpleFunc (void); is a function declaration.
    void simpleFunc (void) is the start of a function definition.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •