tags:

views:

23

answers:

2

I am taking values from array and saving it in linked list as follows:

NSString *formataddr=[RestaurantList objectAtIndex:0];
node1->formattedAddress = (char*)malloc(strlen(formataddr)*sizeof(char)+1);

where formattedaddress is char array. But I'm getting error

passing argument 1 of strlen from incompatible pointer type

Can anyone help me solve this? Thanks!

+1  A: 

You can't use strlen() with NSString *, you have to use [formataddr length].

Williham Totland
+1  A: 

Try

[formataddr length]

instead of strlen(formataddr)

NSString isn't supported by strlen().

Gauloises
Or rather, `strlen()` does not support `NSString *`.
Williham Totland
Right, it only supports C-Strings, my phrasing seems a little bit off today...
Gauloises