Thread: Using data struct and I got an error in struct function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    8

    Using data struct and I got an error in struct function

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
        struct student
         {
    
        string name;
        int grade;
    
    }
    
     int main()
     {
         student people1;
         student people2;
    
    
         cout << "Please enter student name: ";
         cin >> people1.name;
         cout <<" Pleae enter student grade: ";
         cin >> people1.grade;
    
         cout << "Please enter student name: ";
         cin >> people2.name;
         cout <<" Pleae enter student grade: ";
         cin >> people2.grade;
    
    
         system ("pause");
     }








    C:\Users\gameffect\Documents\c++ examples\stringsex.cpp\structex.cpp|6|error: new types may not be defined in a return type|
    C:\Users\gameffect\Documents\c++ examples\stringsex.cpp\structex.cpp|6|note: (perhaps a semicolon is missing after the definition of 'student')|
    C:\Users\gameffect\Documents\c++ examples\stringsex.cpp\structex.cpp|14|error: two or more data types in declaration of 'main'|
    ||=== Build finished: 2 errors, 0 warnings ===|
    Last edited by abrofunky; 02-17-2012 at 07:17 PM. Reason: more clear

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 04-17-2011, 06:36 PM
  2. struct holding data inside a linked list struct
    By icestorm in forum C Programming
    Replies: 2
    Last Post: 10-06-2009, 12:49 PM
  3. Replies: 1
    Last Post: 05-30-2009, 11:04 PM
  4. Error in function, arg of struct pointer.
    By Tronic in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2004, 08:31 PM
  5. which data struct?
    By newbie2c in forum C Programming
    Replies: 3
    Last Post: 01-29-2003, 05:34 PM