well first of all i want to know what are you trying to achieve with the code below. is there something really to it or is it a case of fancy programming?
about warnings and errors. look warnings dont mean everything is ok as you might think. they tell you something is or "might be" wrong with your piece of code. they point out what can go wrong or some kind of ambiguity. warnings are what they are i.e they warn you. at a basic level i think one should have a warning free and error free code. concepts of optimization and compiler and system level considerations come into the picture at a more advanced level. regards, d minotaur ---------------- "the geek will rule the earth" On 5/15/08, bneha69 <[EMAIL PROTECTED]> wrote: > > /*here I am trying to return an integer pointer even when the return > type of the function is int and it works ,just gives warning*/ > void main() > { > int fun1(),*ip; > clrscr(); > ip=fun1();//warning-non-portable pointer conversion > printf("\nip=%u",ip); > getch(); > } > int fun1() > { > int a; > return &a;//warning-non-portable pointer conversion > } > /*here I am trying to return a character pointer even when the > return type of the function is char and it does not work,it gives > error*/ > void main() > { > char fun1(),*cp; > clrscr(); > cp=fun1();//warning-non-portable pointer conversion > printf("\ncp=%u",cp); > getch(); > } > char fun1() > { > char a; > return &a;//error-non-portable pointer conversion > } > /*here I am trying to return a float pointer even when the return > type of the function is float and it does not work,it gives errors*/ > void main() > { > float fun1(),*fp; > clrscr(); > fp=fun1();//error-illegal use of floating-point > printf("\nfp=%u",fp); > getch(); > } > float fun1() > { > float a; > return &a;//error-incompatible type conversion > } > /*here I am trying to return a struct student pointer even when the > return type of the function is struct student and it does not > work,it gives errors*/ > struct student > { > int age; > char *name; > }; > void main() > { > struct student fun1(),*sp; > clrscr(); > sp=fun1();//error-illegal structure opretion > printf("\nsp=%u",sp); > getch(); > } > struct student fun1() > { > struct student a; > return &a;//error-incompatible type conversion > } > > I want to ask that if we return a pointer to int when the function's > return type is int.It works.It does not give any error.But in case > of others' data type ,it gives error. > Why and how does it happen? > > > [Non-text portions of this message have been removed]