Linker error?

This is a discussion on Linker error? within the C++ Programming forums, part of the General Programming Boards category; Ok. So I'm reading C++ Without Fear, and I have to say so far I'm enjoying the book. However, this ...

Linker error?

Ok. So I'm reading C++ Without Fear, and I have to say so far I'm enjoying the book. However, this thread isn't for a book review. I've been using Dev-C++ to compile and run all the example programs in the book and so far it has worked perfectly. Until I got to this program:

From what the linker is saying, an o file is a object file that keeps all the compiled binary data of a program. Perhaps it is having trouble placing it in the file. Try copying and pasting it to anoher file then compile it again. If you get the same error then check the DevC++ help files under linker. The only think I can think of is the object file is not being created. By By the way it should be

Well, unfortunately the author doesn't understand C++ very well. cin.getline() is defined to read in a maximum number of characters that is equal to one character less than what is specified in the second parameter:

cin.getline(name, 99);

So, that line will only read in a maximum of 98 characters, and then it will tack on a '\0' character after the 98th character for a total of 99 characters. However, your array has a size of 100. The second parameter in cin.getline should be the size of your array.

Well, unfortunately the author doesn't understand C++ very well. cin.getline() is defined to read in a maximum number of characters that is equal to one character less than what is specified in the second parameter:

cin.getline(name, 99);

So, that line will only read in a maximum of 98 characters, and then it will tack on a '\0' character after the 98th character for a total of 99 characters. However, your array has a size of 100. The second parameter in cin.getline should be the size of your array.

Hrm. Yeah, I got all that. That's not affecting my ability to compile the program though. I also tried changing the preprocessor directive to #include <cstring> and it still gave me the same problems.

Just to add, that book you have seems to be pretty dataed, what year is it? I have one rather old called Practical C++ which used the old header types to. I used it when I had windows 95 - 98 and used Microsof Visual C++ 6.0 "shoot me.,,,," But thankfully I have upgraded everything since then. I guess the older the book is, the more error prone it will be as older compilers somtimes fail to understand newer functions and ideas

Just to add, that book you have seems to be pretty dataed, what year is it? I have one rather old called Practical C++ which used the old header types to. I used it when I had windows 95 - 98 and used Microsof Visual C++ 6.0 "shoot me.,,,," But thankfully I have upgraded everything since then. I guess the older the book is, the more error prone it will be as older compilers somtimes fail to understand newer functions and ideas