Using STRUCT and FUNCTION

This is a discussion on Using STRUCT and FUNCTION within the C++ Programming forums, part of the General Programming Boards category; nicoqwerty i tried to follow your example but i got 2 errors Code: #include <iostream> using namespace std; struct Carpet ...

  1. #31
    Registered User
    Join Date
    Apr 2010
    Posts
    17
    nicoqwerty

    i tried to follow your example but i got 2 errors

    Code:
    #include <iostream>
    using namespace std;
    
    struct Carpet {
    	float lengthInFeet; 
    	float widthInFeet;
    };
    
    
    float displayArea (Carpet myCarpet)
    	
    --> int main( length * width)
    {
    	struct Carpet myCarpet;
    
    	myCarpet.lengthInFeet=5.62;
    	myCarpet.widthInFeet=2.21;
    	
    	cout<<"Length:" <<myCarpet.lengthInFeet
    	cout<<"Width:" <<myCarpet.widthInFeet
    
    	cout<<"Area is:"; <<displayArea
    
    	return 0;
    }
    
    float displayArea(float length, float width)
    	return(lengthInFeet * widthInFeet)
    }
    C:\Documents and Settings\Administrator\Desktop\proj2\carp2.cpp(12) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
    C:\Documents and Settings\Administrator\Desktop\proj2\carp2.cpp(12) : error C2146: syntax error : missing ';' before identifier 'main'
    C:\Documents and Settings\Administrator\Desktop\proj2\carp2.cpp(12) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.

    carp2.obj - 2 error(s), 1 warning(s)

  2. #32
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    "missing ; before identifier" means maybe you should look on the line above for a missing ;

  3. #33
    Registered User
    Join Date
    Apr 2010
    Posts
    17
    Problem Solved

    Thx to all the users participated in my post.


Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

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