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: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-07-21 11:38

>>43

I really hope that you aren't the same person that said the following..

>>30,31

Would foo evaluate to a pointer to the first element of this > array?

Um... Why, yes, it would.

If you did, you are totally clueless about C. When I run something like the following through gdb

#include <stdio.h>

int main(void) {
  char *p;
  char foo[10];
  p = &foo[0];

  return 0;
}


I get 'foo' as

type = char [10]


but 'p' as

type = char *

In other other words, one is an array of 10 char objects and the other is a pointer.

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