>> strcpy (PCourant->nom, line);
line is a c++ class, strcpy() wants a c style pointer. You have to use std::string's c_str method to get the pointer, like this
strcpy (PCourant->nom, line.c_str());
struct Professeur
{
char nom [20];
Professeur *suivant;
};
Since you are writing a c++ program you should use c++ std::string class, not character arrays, unless your teacher requires you to use character arrays. Using std::string will make your life a lot easier and eleminate several problems with using strcpy() and other similar standard c string handling functions. The main problem with those functions is they will allow you to scribble all over memory by copying strings beyond the allocation of the destination buffer. Example: copy a 25 character string into that buffer that has only room for 19 characters plus null terminator. After that happens your program will likely crash at some point and you will spend hours trying to find the problem.
Last edited by Ancient Dragon; Feb 18th, 2007 at 5:03 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Online 21,949 posts
since Aug 2005