Thread: illegal?

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    13

    illegal?

    can anyone please look at the code below ( its to enter data in to objects in a class) and explain why the structure is illegal....thanks
    its based on OOP principles

    Code:
     cout << "*******************Person Details*********";
    
     cout << "Please enter person name";
     gets(personname);
     Names[i].setName(personname); /*sets name in object in class*/
    
     cout << "data entered as follows:";
     cout << Names[i].getName();
     i++;
    Last edited by fizz_uk83; 08-10-2003 at 02:28 PM.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Code:
    cout << "*******************Person Details*********;
    You forgot the last "
    Away.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    13
    i was told a while back the way the datas entered/objects created is done incorrectly but i cant see how... does anyone know how? thanks

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Use cin.getline( ). Never use gets. Ever. Period.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    When using istreams and ostreams, use only those. Don't mix C-style input/output with C++ style.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C2100 Illegal Indirection error?
    By dnguyen1022 in forum C++ Programming
    Replies: 1
    Last Post: 06-18-2009, 10:47 PM
  2. Replies: 3
    Last Post: 05-24-2009, 02:42 AM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Illegal Characters
    By Echidna in forum Windows Programming
    Replies: 3
    Last Post: 12-08-2002, 04:56 AM