![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| far pointer | useless79 | High Level Programming | 1 | 11-08-2007 01:13 AM |
| A Pointer to non-Virtual Address, and All of my Hard drive | xcoder66 | High Level Programming | 9 | 12-19-2005 01:22 PM |
| pointer | sarwan | High Level Programming | 1 | 11-15-2005 02:41 AM |
| How to Achive IP address through MAC(Ethernet) address | krishnacins | IP Networking | 3 | 08-29-2005 05:45 PM |
| network address and broadcast address? | pnxi | UNIX for Dummies Questions & Answers | 7 | 11-10-2003 07:29 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
address of pointer
Hi i'm new to c programming and i'm trying to change the address of a pointer/variable but i can't seem to get it right,
I have this Code:
char heap[ 134 ];
char *firstFree = heap;
char *allocMem( int size ) {
void *malloc(size_t sizeofint);
/*allocate space for an array with size number of elements of type int*/
int * ip = malloc(sizeof(int) * size);
if(ip == '\0'){ /*If function is null, memory not allocated so return null*/
return '\0';
}else{ /*Otherwise return address of first free space*/
firstFree = *ip+1;
return firstFree;
}
|
| Forum Sponsor | ||
|
|
|
|||
|
Thanks nathan, it worked, but now I'm trying to print all the content of the memory and this isn't printing it, I don't see where I'm going wrong
Code:
char letter;
int counter = 0;
int i;
for (i=0; i < *firstFree; i++){
letter = heap[i];
printf ("%d ",(char) letter);
counter++;
if(counter==10){
counter = 0;
printf("\n");
}
}
|