cancel
Showing results for 
Search instead for 
Did you mean: 

can anyone program in c?

N/A

can anyone program in c?

i am a beginner at programming and am having some difficulty. does anybody know what to put for the following function. i have put the function and a comment about what it should do
thanks :roll:

crimADT createCriminal(char *name, char *offence, float height, int offences);

/* creates a new criminal record with the data passed in and returns a pointer to it */
9 REPLIES
N/A

can anyone program in c?

What exactly do you mean by
Quote
does anybody know what to put for the following function
?

Are you looking for someone to write the code for the function?
N/A

can anyone program in c?

well i just need some guidance for doing it with recursion. do the variables have to declared etc? i know it probably very simple but it seems to be baffling me more than other methods i am using
N/A

can anyone program in c?

recursion is a useful tool in C, but I'm not quite sure how you planned to apply recursion for this function you've listed.

A recursive routine is like any other, you need to declare the variables etc, but bear in mind that you need to make sure that it does end at some point, or else your machine will freeze. It's this danger which is why not every programming language will allow recursive functions.
N/A

can anyone program in c?

i am sorry this is still not making sense to me!!! how do i start?? i understand about the recursion now but just dont kno whow to write this function and what to put in it
N/A

can anyone program in c?

Before you write this function, you need to understand how the recursion will affect your function and how by calling the function from inside the function, the data will follow.

Recusive functions are used on file sorting for example.

What is the end result that you want to achive, start with that first, then slowly work your way down to understand how you achive the end result. This is called top down programming.

If you dive straight into the code, you get can get lost in the code and not understand where you want to get to.

Does this make sense? The details of the function are not enough to go on, all you've told me is the basic parameters of the function, not what you intend it to do and the end result.

What about the interface to the function, what is going to call the function? how do you thing rescursion will help you?

Aaron
N/A

can anyone program in c?

i am using it within a library i am creating. it needs to be able to creat a record with the data passed in and return a pointer to it. after i have written the libraries i have create a test program
N/A

can anyone program in c?

A recursive procedure/function needs to terminate correctly. It will need what is usually called an anchor value/values. How do you know the recursion will stop? If not, your computer will rapidly run out of "stack" memory and crash!
N/A

can anyone program in c?

But what your describing is not a recursive function, and when you say you're creating data, where on disk, within memory. Are you creating a class? where criminal is the class and the name you pass is the instance of that class?

As I have had said previously and mariglenn has just re-mentioned, you must make sure a recursive routine ends in a controlled fashion or else your PC will crash.

What is the overall program that your trying to create? what does it? what is it's purpose? How does this function fit into the program? what is it's purpose within the program?

Sorry if I'm asking lots of questions, but you've not given me much to go and I don't know how much of an understanding you have of C, how long you learning it etc.
N/A

can anyone program in c?

I think we need to see the code of the function. [Sorry, gadgetboy, I didn't read all the posts above Shockedops: ]