This code produces - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# This code produces

Posts: 140Member
include

void xxx( int*, int);
void main()
{
int x =4, y = 13;
xxx(&x, y);
printf("%d%d
", x, y);
}

void xxx(int* x, int y)
{
*x += 4;
y += 7;
printf("%d%d
", *x, y);
}

820
813

I cant understand why-

• Posts: 9,765Member ✭✭✭
[b][red]This message was edited by stober at 2005-8-8 16:48:40[/red][/b][hr]
: include
:
: void xxx( int*, int);
: void main()
: {
: int x =4, y = 13;
: xxx(&x, y);
: printf("%d%d
", x, y);
: }
:
: void xxx(int* x, int y)
: {
: *x += 4;
: y += 7;
: printf("%d%d
", *x, y);
: }
:
:
: 820
: 813
:
: I cant understand why-
:

you need to separate the numbers with one or more spaces -- they are all run togethere.
[code]
: printf("%d %d
", *x, y);
[/code]

• Posts: 694Member ✭✭✭
Look at your format specifiers in the printf statements

%d%d will make two numbers appear as one, or if you don't know where the 8 came from, then read up on pointers a bit more.

: include
:
: void xxx( int*, int);
: void main()
: {
: int x =4, y = 13;
: xxx(&x, y);
: printf("%d%d
", x, y);
: }
:
: void xxx(int* x, int y)
: {
: *x += 4;
: y += 7;
: printf("%d%d
", *x, y);
: }
:
:
: 820
: 813
:
: I cant understand why-
: