Join us at IRC!
One mans freedom fighter, another's terrorist.
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 23
Web Spiders: 14
Guests Online: 23
Members Online: 0

Registered Members: 70189
Newest Member: CrownClown
Latest Articles
View Thread

HellBound Hackers | HellBound Hackers | Questions

Author

I'm new to programming in C.

TweakedEh
Member



Posts: 6
Location:
Joined: 11.06.08
Rank:
Newbie
Posted on 27-06-08 07:54
I took most of this from a book and tryed to add my own code to see if I could get it to work. int y doesn't print 120 and I'm not too sure why. I don't want the answer I would like hits on what I did wrong.



#include <stdio.h> /* standard i/o include file*/

struct xampl {
int x;
int y;
};

int main()
{
struct xampl structure;
struct xampl *ptr;
struct xampl y;

structure.x = 12;
structure.y = 120;

ptr = &structure;

printf( "%d\n", ptr->x ); /* The -> acts somewhat like the * But it gets what is at that memory address*/
printf("%d\n", y);


getchar();
return 0;
}
Author

RE: I'm new to programming in C.

ghostontherun
Member



Posts: 13
Location:
Joined: 09.11.06
Rank:
Hacker Level 1
Posted on 27-06-08 08:08
// printf("%d\n", y);
this is wrong !
it should be printf("%d\n",structure.y);
use the structure variable
ghostontherun1
Author

RE: I'm new to programming in C.

TweakedEh
Member



Posts: 6
Location:
Joined: 11.06.08
Rank:
Newbie
Posted on 27-06-08 08:10
TweakedEh wrote:
I don't want the answer I would like hits on what I did wrong.


Thanks for the help but I wouldn't mind a hint next time ;)
Author

RE: I'm new to programming in C.

Uber0n
Member



Posts: 1963
Location: Sweden‭‮
Joined: 13.06.06
Rank:
God
Posted on 27-06-08 11:43
So you can't code in C but you don't want people to tell you exactly what's wrong with your code...? :right:



http://uber0n.webs.com/
Nope http://uber0n.webs.com/
Author

RE: I'm new to programming in C.

K_I_N_G
Member



Posts: 356
Location: ?
Joined: 04.03.08
Rank:
Elite
Posted on 27-06-08 11:49
...dude.... Thats fucking annoying, your being ignorant and unclear. Why dont you bury your computer in Egypt and try to shove a pyramid up your ass cuz thats about all your 'intellectual' mind will be able to comprehend.
Nah jk haha. Just don't be so annoying, consider yourself mildly chastised/flamed.


Author

RE: I'm new to programming in C.

TweakedEh
Member



Posts: 6
Location:
Joined: 11.06.08
Rank:
Newbie
Posted on 27-06-08 18:52
Uber0n wrote:
So you can't code in C but you don't want people to tell you exactly what's wrong with your code...? :right:


No, I can code in C but not a lot. I'm still learning and couldn't find my mistake. I have a book here that I am reading, I added some of my own code to that to have a better understaning of what it does and how it works. I asked for a hint because I don't like being spoon fed.
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.