Code: #include<stdio.h> main(int argc, char **argv) { char *ptr1; char **ptr2; char ***ptr3; char arr[10][10]; ptr1=arr; [B]ptr2=arr;[/B] ptr3=arr; } why i'm getting warnings for all the assignments.... which assignment is correct.. and why.... please
I am not sure why you are getting warning but I get errors. Code: error C2440: '=' : cannot convert from 'char [10][10]' to 'char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2440: '=' : cannot convert from 'char [10][10]' to 'char ** ' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast error C2440: '=' : cannot convert from 'char [10][10]' to 'char *** ' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast and the warning is for the main not returning anything. Code: warning C4508: 'main' : function should return a value; 'void' return type assumed
It was surprised to get u warnings instead of errors. Anyhave , I think that u r trying to point a 2D character array using pointer variable.... To attained it just use ptr1=arr[0];(i.e enough) ptr2 and ptr3 are not at all needed.........