Programming (1 Viewer)

Loppan

Senior Member
Jul 13, 2002
2,528
#1
I need help with pointers in C.

I have one function that is gonna call two other functions where one fuction looks something like this:

void one(int *pointer, int n1, int n2) {

*pointer=n1+n2;

}

and the other looks the same but without pointers.
 

Buy on AliExpress.com

gray

Senior Member
Moderator
Apr 22, 2003
30,260
#4
hmmm i dun think those are legal
i don't think u can use:

*pointer = n1 + n2,

since pointer holds addresses and n1 + n2 is a value not an address, and if u want the pointer to point at the sum then it has to pioint to a variable with that sum
 

mikhail

Senior Member
Jan 24, 2003
9,576
#5
Gray talks sense man. I think (pointers weren't my strong point, quite the opposite in fact) that you can say that

a = n1 + n2

and set *pointer equal to the address of a. Anyone know if that is &a?
 

Martin

Senior Member
Dec 31, 2000
56,913
#8
Yes, I know, it's pathetic :down:

For some reason, c isn't mandatory here, but I plan on taking a c course next year.
 

Majed

Senior Member
Jul 17, 2002
9,630
#12
Learning new high-level programming languages isn't tough at all, but learning learnign crap like assembly! can cause brain damage! :dazed: :wth: :stress:
 

Martin

Senior Member
Dec 31, 2000
56,913
#13
I'm just saying it like it is, Mayood :)

I never tried assembly but then it never looked like anything I wanted to get into, just seeing a page of asm code makes me dizzy. :D
 

Majed

Senior Member
Jul 17, 2002
9,630
#14
++ [ originally posted by Alex ] ++
I'm just saying it like it is, Mayood :)

I never tried assembly but then it never looked like anything I wanted to get into, just seeing a page of asm code makes me dizzy. :D
lucky you...i hope you never have the bad luck to be assigned something in assembly!!


try making a damn bowling score-keeper program using assembly!! :stress: :crazy:


makes me wonder weather windows/DOS was really programmed by exiled lunatic aliens!
 

Majed

Senior Member
Jul 17, 2002
9,630
#18
++ [ originally posted by Alex ] ++
:LOL:

Not funny when I remember all my programming exams have been on paper :groan:
yeah! :groan:....paper!!...so, last century! ;) (in a clueless teenage-girl accent :D )
 

gray

Senior Member
Moderator
Apr 22, 2003
30,260
#19
++ [ originally posted by Alex ] ++
:LOL:

Not funny when I remember all my programming exams have been on paper :groan:
Mine are still like that! Well I guess there's one good thing about that.... it's not like they're gonna try compile your code and get a bug report... but then again, I don't know myself when there's errors in there... I'm just too used to compiling every few seconds..
 

Martin

Senior Member
Dec 31, 2000
56,913
#20
++ [ originally posted by gray ] ++
Mine are still like that! Well I guess there's one good thing about that.... it's not like they're gonna try compile your code and get a bug report... but then again, I don't know myself when there's errors in there... I'm just too used to compiling every few seconds..
Exactly, but most of all I can't plan my code like that, esp if the problem is difficult. In an editor I can copy, paste, move etc. On paper it's a mess and I can't see what's what. :mad:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)