Okay, so I'm on Chapter 6 already in "Learn C on the Mac". I must say it's much easier than my other book, but it clearly doesn't teach me nearly as much as my other book. I'm way beyond "Learn C on the Mac" Ch. 6. There's only 4 more chapters in the book! I don't think it's going to cover everything that my other book covers, in which I still have 18 more chapters!!
But anyway, it's serving it's purpose, filling in some knowledge gaps and making some concepts seem easier. Good to augment the learning process.
Anyway, my question is about functions. I've just learned what functions are in C. And from what I understand one of the benefits of naming a function is so I can call that function in the future without having to rewrite all the code. Am I correct on this?
In other words, if I write a small program that alphabetizes user input. I can name this main function something. Then if I'm writing a larger program, and I need to alphabetize within the larger program, rather than re-write the code, I can just insert my "new" function? Is this true? Is it also true that I won't see the code in my larger program? But only see the function. The function will do it's work behind the scenes?
Assuming all this is correct, I haven't learned exactly how and where I save my function?? If I write a function, where do I "save" it?? If I write a completely different program and insert my function, how will the new program know where to find the code for my function?
Lastly, if a friend needed code that did something, and I had it. Can I somehow give him the function that will do what he wants it to do, without revealing the source code??
Thanks
Scott
But anyway, it's serving it's purpose, filling in some knowledge gaps and making some concepts seem easier. Good to augment the learning process.
Anyway, my question is about functions. I've just learned what functions are in C. And from what I understand one of the benefits of naming a function is so I can call that function in the future without having to rewrite all the code. Am I correct on this?
In other words, if I write a small program that alphabetizes user input. I can name this main function something. Then if I'm writing a larger program, and I need to alphabetize within the larger program, rather than re-write the code, I can just insert my "new" function? Is this true? Is it also true that I won't see the code in my larger program? But only see the function. The function will do it's work behind the scenes?
Assuming all this is correct, I haven't learned exactly how and where I save my function?? If I write a function, where do I "save" it?? If I write a completely different program and insert my function, how will the new program know where to find the code for my function?
Lastly, if a friend needed code that did something, and I had it. Can I somehow give him the function that will do what he wants it to do, without revealing the source code??
Thanks
Scott