From: "Lennart Marien" Newsgroups: comp.os.msdos.djgpp Subject: malloc? Date: Wed, 29 Apr 1998 21:27:56 +0200 Organization: Metronet Lines: 61 Message-ID: <6i7v0o$ns6$1@news.metronet.de> NNTP-Posting-Host: hamburg1.pop.metronet.de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! I have a severe problem which is bothering since hours.What Iīm trying o do is the following in pseudo code:(the struct PCXHeader is declared before) int handle; short width,heigth; void addr_of_buf; void readheaderPCX(char *fd,struct PCXHeader *header) /*this function works*/ { handle=open(fd,O_BINARY); read(handle,header,sizeof(*header)); }; void readln(char *buffer,short width) { /*buffer is a pointer to a variable like 'char buffer[width]'*/ [.....] /*The routine reads data bytes and expands them into buffer until buffer is full*/ }; void loadpcx(int x, int y, char *fd) { struct PCXHeader h; readheader(fd,&h); /*works*/ width=h.x2-h.x1; heigth=h.y2-h.y1; /*donīt know if you understand, but it works*/ addr_of_buf=malloc(width); [...] /*the program reads data line and shows it....*/ }; Hope this wasnīt confusing if so here is it in text: I read some information from an 8Bit-PCX file to compute the height and the width of the picture.Then a buffer is allocated to contain one line of a pic.Since itīs an 8Bit file the variable would look like char buffer[width]. A Pointer addr_of_buf should contain the address of the allocated memory using malloc: addr_of_buf=malloc(width); Now a function called readln reads WIDTH bytes from the file and puts them into the buffer.My question is actually about malloc hy doesnīt it work? I always get an error message if I try to address my memory like this: *addr_of_buf[10]=0; He tells me of some unary operator *? What can I do? Thanks in advance!!!!! cu