# Pointers and Functions

Page 1 of 1

## 2 Replies - 888 Views - Last Post: 03 March 2010 - 09:28 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=159549&amp;s=0b23482b8727ed2d3955b8f7d551d671&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 girly_engineer

Reputation: 1
• Posts: 16
• Joined: 02-February 09

# Pointers and Functions

Posted 03 March 2010 - 09:07 AM

deleted

This post has been edited by girly_engineer: 03 March 2010 - 01:07 PM

Is This A Good Question/Topic? 0

## Replies To: Pointers and Functions

### #2 Martyn.Rae

• The programming dinosaur

Reputation: 545
• Posts: 1,420
• Joined: 22-August 09

## Re: Pointers and Functions

Posted 03 March 2010 - 09:16 AM

Your problem is in the get_int routine. I have corrected it for you below. The routine is called from the get_fraction routine with it's two parameters which are pointers to type int. The scanf routine therefore does not require the address-of & operator, as that would make them pointer to pointer to int. Also the while statement needs a dereference on both the original_num and original_denom as you are accessing the int rather than referring to it's pointer.

You also didn't put any types for the parameters of get int.

```void get_int(int *original_num, int *original_denom)
{
do
{
printf("Numerator: ");
scanf("%d", original_num);
while(getchar() != '\n');
if(*original_num <= 0)
{
printf("Please enter an integer greater than 0\n");
}
} while(*original_num <= 0);

do
{
printf("Denominator: ");
scanf("%d", original_denom);
while(getchar() != '\n');
if(*original_denom <= 0)
{
printf("Please enter an integer greater than 0\n");
}
} while(*original_denom <= 0);

}

```

Hope you followed all of that.

### #3 girly_engineer

Reputation: 1
• Posts: 16
• Joined: 02-February 09

## Re: Pointers and Functions

Posted 03 March 2010 - 09:28 AM

Thank you very much. I think I need to read over pointers and functions again until I completely understand. I was under the impression that I couldn't use the functions void get_int and void get_fraction with the same parameters