ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Well there are a few things to do, and note what you wrote is C not C++. (Subtle difference, ) To maintain compatibility with your main() you'll want to not make newpw a pointer, rather an array... like this
And this program suffers from a buffer overflow too in main() from char entered. What if I enter a password that is 1024 characters long? Think of a solution for that. Also note that a bash script that uses mkpasswd would probably be easier to write, more effient, and more secure.
portability. There are more C compilers out there than c++ compilers. Once upon a time the gnu c++ compiler generated slower code, even when invoked on valid C -- I don't know if that's still true. Still, if you are going to require a c++ compiler you might was well make use of the stl <string> class or at least switch to operator "new" and "delete" instead of malloc/calloc/free. If your code gets linked to other peoples' projects, it's doubly important for it to not be schizophenic about it's c or c++ness, as they link differently.