Explain me.... why

mckk84's Avatar, Join Date: Jun 2007
Newbie Member
Code:
#include<stdio.h>
main(int argc, char **argv)
{
        char *ptr1;
        char **ptr2;
        char ***ptr3;
        char arr[10][10];
        ptr1=arr;
        ptr2=arr;
        ptr3=arr;
}

why i'm getting warnings for all the assignments.... which assignment is correct.. and why.... please

Last edited by shabbir; 20Aug2007 at 20:46.. Reason: Code block - http://www.go4expert.com/forums/misc.php?do=bbcode#code
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
You want free help? Don't be rude. Read this.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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
0
seeguna's Avatar
Go4Expert Member
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.........