Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C Question

Name: Anonymous 2011-07-19 2:02

Im going to be taking Intro to C in the fall so I have decided to read up on the textbook and learn how to program before the semester starts. I'm having a little problem, here's the trouble maker:
    potr1 = &goodarray[0];

    potr2 = &goodarray;

for some reason potr2 gets assigned the value of the &goodarray[0]instead of the &goodarray itself.. I have verified this by printfing both of them and they come up the same number. Im using DevC++ and Im pretty sure I just need to find a better compiler, but am I doing something wrong?

Name: Anonymous 2011-07-21 17:41

I can't believe we have a tripfag this stupid hanging around.

Hey if I have int x[10];, what does x evaluate to?

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-07-21 17:46

>>81
This is int [10].

Now if you are going to say this is a pointer, that is incorrect, because &x is

int (*)[10]

Or pointer to int[10].

Name: Anonymous 2011-07-21 17:51

>>82
More to the point, something like int[10] is an array of 10 integer objects.

Name: Anonymous 2011-07-21 18:29

>>82
x evaluates to a pointer to its first element, ``faggot''.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-07-21 18:46

>>84
No it doesn't. It evaluates to an array of 10 integer elements.

In contrast, if I had something like

char (*q)[10] = &a;

Then &a[0] would *point* to the first element because q is a pointer to char[10].

Name: Anonymous 2011-07-21 18:56

>>85
do you even know what "to evaluate" means?

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-07-21 19:01

>>86
In strict computer science terms? Or in your retarded blue collar worker terms? Either way, the evaluation only bears relevance when something like &a gets evaluated to a number at runtime. As opposed to say, compile time.

Name: Anonymous 2011-07-21 19:06

>>86
And if you really think the evaluation of statement

int a[10];

has any impact on your misinformed notions about the relationship between an array elmetn and a pointer in C, then you really are that fucking stupid.

Name: Anonymous 2011-07-21 20:05

>>88
int a[10]; is not a statement, it's a declaration.

Name: Anonymous 2011-07-21 20:13

>>85
No it doesn't. It evaluates to an array of 10 integer elements.
There are no array-typed values, friend.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-07-21 20:24

>>89
I looked it up in ANSI/ISO C 89/99. It's a statement because the expression ends with a semicolon.

>>90
But there are an array of objects that has some type T.

Name: Anonymous 2011-07-21 20:41

>>91
I looked it up in ANSI/ISO C 89/99. It's a statement because the expression ends with a semicolon.
Quote it.

Name: Anonymous 2011-07-21 21:00

>>92
Page 132, section 6.8.3

The syntax allows for the expression to end with a semi-colon.

Name: Anonymous 2011-07-21 21:12

C sucks

Name: Anonymous 2011-07-21 22:09

SICP is mush-brained drivel by a pseudo-intellectual cockpouch. It's right up there with TAOCP and K&R as things that idiots read to make people think they're smart.

Name: Anonymous 2011-07-22 3:34

So, this is why the imageboard scum hates so much ``tripfags''. Interesting, they've got a point.

Name: Anonymous 2011-07-23 0:39

>>95
i loled

Name: Anonymous 2011-07-23 0:50

>>95
It's right up there with TAOCP and K&R
You forgot Thinking Forth.

Name: Anonymous 2011-07-23 0:53

>>98
and The Mythical Man-Month is definetely a book, "idiots" read.

Name: Anonymous 2011-07-23 4:55

>>99
everyone knows that the best way to make software is by hiring more enterprise-quality programmers from India until it is finished.

Name: Argus !!14eWW2o34yaxKWG 2011-07-23 9:00


int main(int argc, const char * argv[])
{
     char array[10] = "fuck you!"; //a simple character array
     char *p_one, *p_two;              //two character pointers
    
     p_one = &array;      //(array)
     p_two = &array[2];   //(array+2)

     printf("%s\n", array);  //not useful to the discussion
     return 0;               //slower than void return.
}


>>1
yep, arrays are fancy addressing systems, your mistake is that you believe that the array is a pointer itself, and has some location in memory.  The fact is, however, that an array IS simply an address. therefore the statement:
potr2 = &goodarray;
Is simply you trying to get the address of an address.  Your compiler gave you a break by not raping you in the eye and telling you to kill yourself; but you were still being retarded.  The part that gets me is that you were so blindly confident that an array was a pointer that you started this thread.

Name: Anonymous 2011-07-23 11:20

>>101
const char * argv[]
>const
>IHBT

p_one = &array;
That's just plain wrong.

Name: Anonymous 2011-07-23 15:22

p_one = &array;
Not OPTIMIZED!
p_one = array;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List