Kunal Gangakhedkar wrote:
In this case, what you need to do is advance the arg pointer. Something like
for( i =0 ; i < 4; i++) { if((*(arg + i) = (char *)malloc(n * sizeof(char))) == NULL)
LHS should be *(arg + i * sizeof(char *)) As pointers(arg is pointer to pointer) are NOT 1 byte long. Size depends on system. Generally 4 byte.
Amish.
On Sunday 29 September 2002 09:31 am, Amish Mehta wrote:
for( i =0 ; i < 4; i++) { if((*(arg + i) = (char *)malloc(n * sizeof(char))) == NULL)
LHS should be *(arg + i * sizeof(char *)) As pointers(arg is pointer to pointer) are NOT 1 byte long. Size depends on system. Generally 4 byte.
No, it does not need to be.... Pointers are internally ints (unsigned ??), no matter whatever be the system.... So, it will automatically take whatever the system uses for address manipulation. For example, on DOS, int = 2 bytes(16 bits) = pointer. That is why you need far & near pointers in DOS to access longer memory addresses. In case of Win32 ( GCC )/Linux, int = 4 bytes(32 bits) = pointer. Hence, a single pointer can access all the addresses.
That is why, programs using 16 bit code on linux need to define new ints having 16 bits - like GTK's gint16.
Amish Mehta wrote:
Kunal Gangakhedkar wrote:
In this case, what you need to do is advance the arg pointer. Something like
for( i =0 ; i < 4; i++) { if((*(arg + i) = (char *)malloc(n
- sizeof(char))) == NULL)
LHS should be *(arg + i * sizeof(char *)) As pointers(arg is
Nope. arg + 1 will increment sizeof(char*) bytes, not 1. Pointer arithmetic.
Manish
Hello Luggers,
On behalf of the ILUG-BOM the following are gonna conduct a workshop on Gnu-Linux in sangli and are also looking forward to having such regular workshops all over the country.
--> http://members.fortunecity.com/csesarit/
-- Dr Nagarjuna -- Sameer D.S -- Dinesh Shah -- Ravindra Jaju -- G Tapeshwar -- Shankar R -- Trevor Warren
We need FREEBIES/GIFTS/BOOKS/Gnu-Linux toys............etc that could be handed out by us as prizes for the various competitions that we are gonna conduct during the course of the workshop.
We would be ready to put up banners/advertising info if that would help propogate the DONORS message.
Call me on 9820349221/8312930-31 and speak to me.
This is on priority as the workshop at Rajaram Bapu College Of Engineering is coming up this week end.
Trevor
===== ( >- GNU/LINUX, It's all about CHOICE -< ) /~\ __ http://www.qmailtheeasyway.com __ /~\ | ) / mailto: trevor.w@media.mit.edu \ (/ | |_|_ \ Research Asst, MediaLab / _|_| ___________________________________/
__________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com